From 24049149253f29f0b4bd7070aeabf88fc5af68e7 Mon Sep 17 00:00:00 2001 From: Steve Chaplin Date: Thu, 20 May 2010 09:52:34 +0800 Subject: Update tests. --- INSTALL | 6 +-- examples/cairo_snippets/snippets_png.py | 66 +++++++++++++------------- test/Makefile.am | 5 +- test/README | 13 +++++ test/api_test.py | 84 +++++++++++++++++++++++---------- test/examples_test.py | 34 +++++++------ test/isurface_create_for_data1.py | 25 ++++++---- test/isurface_create_for_data2.py | 24 ++++++---- test/isurface_create_from_png.py | 59 +++++++++++++++-------- test/isurface_get_data.py | 13 +++-- test/pygame-test1.py | 28 +++++------ test/pygame-test2.py | 28 +++++------ test/surface_create_for_stream.py | 56 +++++++++++----------- test/surface_write_to_png.py | 28 ++++++----- 14 files changed, 279 insertions(+), 190 deletions(-) create mode 100644 test/README diff --git a/INSTALL b/INSTALL index 1d4e3fd..9e2b471 100644 --- a/INSTALL +++ b/INSTALL @@ -31,8 +31,4 @@ $ python setup.py install Testing ------- -The tests use py.test from pylib -http://codespeak.net/py/dist/ - -$ cd test -$ py.test +See test/README diff --git a/examples/cairo_snippets/snippets_png.py b/examples/cairo_snippets/snippets_png.py index b499c6c..5341979 100755 --- a/examples/cairo_snippets/snippets_png.py +++ b/examples/cairo_snippets/snippets_png.py @@ -7,8 +7,8 @@ from math import pi as M_PI # used by many snippets import sys import cairo -if not cairo.HAS_PNG_FUNCTIONS: - raise SystemExit ('cairo was not compiled with PNG support') +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') from snippets import snip_list, snippet_normalize @@ -17,36 +17,36 @@ width, height = 256, 256 # used by snippet_normalize() def do_snippet (snippet): - if verbose_mode: - print 'processing %s' % snippet, - - surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, width, height) - cr = cairo.Context (surface) - - cr.save() - try: - execfile ('snippets/%s.py' % snippet, globals(), locals()) - except: -# exc_type, exc_value = sys.exc_info()[:2] -# print >> sys.stderr, exc_type, exc_value - raise - else: - cr.restore() - surface.write_to_png ('snippets/%s.png' % snippet) - - if verbose_mode: - print + if verbose_mode: + print 'processing %s' % snippet, + + surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, width, height) + cr = cairo.Context (surface) + + cr.save() + try: + execfile ('snippets/%s.py' % snippet, globals(), locals()) + except: +# exc_type, exc_value = sys.exc_info()[:2] +# print >> sys.stderr, exc_type, exc_value + raise + else: + cr.restore() + surface.write_to_png ('snippets/%s.png' % snippet) + + if verbose_mode: + print if __name__ == '__main__': - verbose_mode = True - if len(sys.argv) > 1 and sys.argv[1] == '-s': - verbose_mode = False - del sys.argv[1] - - if len(sys.argv) > 1: # do specified snippets - snippet_list = sys.argv[1:] - else: # do all snippets - snippet_list = snip_list - - for s in snippet_list: - do_snippet (s) + verbose_mode = True + if len(sys.argv) > 1 and sys.argv[1] == '-s': + verbose_mode = False + del sys.argv[1] + + if len(sys.argv) > 1: # do specified snippets + snippet_list = sys.argv[1:] + else: # do all snippets + snippet_list = snip_list + + for s in snippet_list: + do_snippet (s) diff --git a/test/Makefile.am b/test/Makefile.am index af0a436..7ca29c4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,7 @@ EXTRA_DIST = \ - examples_test.py + README \ + api_test.py \ + examples_test.py \ isurface_create_for_data1.py \ isurface_create_for_data2.py \ isurface_create_from_png.py \ @@ -8,4 +10,3 @@ EXTRA_DIST = \ pygame-test2.py \ surface_create_for_stream.py \ surface_write_to_png.py - diff --git a/test/README b/test/README new file mode 100644 index 0000000..15a9b7d --- /dev/null +++ b/test/README @@ -0,0 +1,13 @@ +pycairo tests +------------- + +The main test files are the '*_test.py' files. +They use py.test from pylib. +http://codespeak.net/py/dist/ + +$ cd test +$ py.test + +The other files are tests that were used to test/develop specific +functions. They usually require you run the test and then visually examine the +output. diff --git a/test/api_test.py b/test/api_test.py index 6a8db8c..47d3520 100644 --- a/test/api_test.py +++ b/test/api_test.py @@ -14,41 +14,77 @@ import py.test as test def test_context(): - pass + if cairo.HAS_IMAGE_SURFACE: + f, w, h = cairo.FORMAT_ARGB32, 100, 100 + s = cairo.ImageSurface(f, w, h) + ctx = cairo.Context(s) + ctx.set_source_rgb(1.0, 1.0, 1.0) + ctx.set_operator(cairo.OPERATOR_SOURCE) + ctx.paint() + def test_matrix(): - pass + m = cairo.Matrix() + m.rotate(10) + m.scale(1.5, 2.5) + m.translate(10, 20) + def test_path(): - pass + # AttributeError: 'module' object has no attribute 'Path' + test.raises(AttributeError, "p = cairo.Path()") + # see examples/warpedtext.py + + +def test_pattern(): + # TypeError: The Pattern type cannot be instantiated + test.raises(TypeError, "p = cairo.Pattern()") + + r,g,b,a = 0.1, 0.2, 0.3, 0.4 + p = cairo.SolidPattern(r,g,b,a) + assert p.get_rgba() == (r,g,b,a) + + # SurfacePattern + + # TypeError: The Gradient type cannot be instantiated + test.raises(TypeError, "p = cairo.Gradient()") + + x0,y0,x1,y1 = 0.0, 0.0, 0.0, 1.0 + p = cairo.LinearGradient(x0,y0,x1,y1) + assert p.get_linear_points() == (x0,y0,x1,y1) + p.add_color_stop_rgba(1, 0, 0, 0, 1) + p.add_color_stop_rgba(0, 1, 1, 1, 1) -def test_patterns(): - pass + cx0, cy0, radius0, cx1, cy1, radius1 = 1.0, 1.0, 1.0, 2.0, 2.0, 1.0 + p = cairo.RadialGradient(cx0, cy0, radius0, cx1, cy1, radius1) + assert p.get_radial_circles() == (cx0, cy0, radius0, cx1, cy1, radius1) + p.add_color_stop_rgba(0, 1, 1, 1, 1) + p.add_color_stop_rgba(1, 0, 0, 0, 1) -def test_surfaces(): - # The Surface type cannot be instantiated - test.raises(TypeError, "s = cairo.Surface()") +def test_surface(): + # TypeError: The Surface type cannot be instantiated + test.raises(TypeError, "s = cairo.Surface()") - if cairo.HAS_IMAGE_SURFACE: - f, w, h = cairo.FORMAT_ARGB32, 100, 100 - s = cairo.ImageSurface(f, w, h) - assert s.get_format() == f - assert s.get_width() == w - assert s.get_height() == h + if cairo.HAS_IMAGE_SURFACE: + f, w, h = cairo.FORMAT_ARGB32, 100, 100 + s = cairo.ImageSurface(f, w, h) + assert s.get_format() == f + assert s.get_width() == w + assert s.get_height() == h - if cairo.HAS_PDF_SURFACE: - f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 - s = cairo.PDFSurface(f, w, h) + if cairo.HAS_PDF_SURFACE: + f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 + s = cairo.PDFSurface(f, w, h) - if cairo.HAS_PS_SURFACE: - f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 - s = cairo.PSSurface(f, w, h) + if cairo.HAS_PS_SURFACE: + f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 + s = cairo.PSSurface(f, w, h) - if cairo.HAS_SVG_SURFACE: - f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 - s = cairo.SVGSurface(f, w, h) + if cairo.HAS_SVG_SURFACE: + f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 + s = cairo.SVGSurface(f, w, h) def test_text(): - pass + pass diff --git a/test/examples_test.py b/test/examples_test.py index f5fe924..ab85514 100644 --- a/test/examples_test.py +++ b/test/examples_test.py @@ -8,22 +8,26 @@ import os import os.path import subprocess +import cairo #import py.test as test -def test_examples(): - '''run non-gui example scripts and check they exit successfully. - ''' - os.chdir(os.path.join(os.path.dirname(__file__), '..', 'examples')) - for f in (x for x in os.listdir('.') if x.endswith('.py')): - retcode = subprocess.call('python %s' % f, shell=True) - assert retcode == 0, 'Error: {0} retcode == {1}'.format(f, retcode) - - -def test_snippets_png(): - '''run all snippets in png mode and check they exit successfully. - ''' - os.chdir(os.path.join(os.path.dirname(__file__), '..', 'examples', - 'cairo_snippets')) - retcode = subprocess.call('python snippets_png.py -s', shell=True) +def test_snippets(): + '''Run all snippets in png,pdf,ps,svg mode and check they exit successfully. + This will create *.{pdf,png,ps,svg} output files in + examples/cairo_snippets/snippets/ + ''' + def doSnippets(name): + retcode = subprocess.call('python %s -s' % name, shell=True) assert retcode == 0, 'Error: retcode == {0}'.format(retcode) + + os.chdir(os.path.join(os.path.dirname(__file__), '..', 'examples', + 'cairo_snippets')) + if cairo.HAS_PDF_SURFACE: + doSnippets('snippets_pdf.py') + if cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS: + doSnippets('snippets_png.py') + if cairo.HAS_PS_SURFACE: + doSnippets('snippets_ps.py') + if cairo.HAS_SVG_SURFACE: + doSnippets('snippets_svg.py') diff --git a/test/isurface_create_for_data1.py b/test/isurface_create_for_data1.py index c497991..867fde4 100755 --- a/test/isurface_create_for_data1.py +++ b/test/isurface_create_for_data1.py @@ -3,25 +3,30 @@ """ import array +import tempfile import cairo -dir_ = "/tmp/" +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') + +h, fileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') width, height = 255, 255 data = array.array('B', [0] * width * height * 4) for y in range(height): - for x in range(width): - offset = (x + (y * width)) * 4 - alpha = y + for x in range(width): + offset = (x + (y * width)) * 4 + alpha = y - # cairo.FORMAT_ARGB32 uses pre-multiplied alpha - data[offset+0] = int(x * alpha/255.0) # B - data[offset+1] = int(y * alpha/255.0) # G - data[offset+2] = 0 # R - data[offset+3] = alpha # A + # cairo.FORMAT_ARGB32 uses pre-multiplied alpha + data[offset+0] = int(x * alpha/255.0) # B + data[offset+1] = int(y * alpha/255.0) # G + data[offset+2] = 0 # R + data[offset+3] = alpha # A surface = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32, width, height) ctx = cairo.Context(surface) -surface.write_to_png(dir_ + 'for_data1.png') +surface.write_to_png(fileName) +print "see %s output file" % fileName diff --git a/test/isurface_create_for_data2.py b/test/isurface_create_for_data2.py index 88b4c5c..c4f290b 100755 --- a/test/isurface_create_for_data2.py +++ b/test/isurface_create_for_data2.py @@ -1,26 +1,30 @@ #!/usr/bin/env python """test cairo.ImageSurface.create_for_data() with a numpy array """ +import tempfile import cairo - import numpy -dir_ = "/tmp/" +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') + +h, fileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') width, height = 255, 255 data = numpy.ndarray (shape=(height,width,4), dtype=numpy.uint8) for x in range(width): - for y in range(height): - alpha = y + for y in range(height): + alpha = y - # cairo.FORMAT_ARGB32 uses pre-multiplied alpha - data[y][x][0] = int(x * alpha/255.0) - data[y][x][1] = int(y * alpha/255.0) - data[y][x][2] = 0 - data[y][x][3] = alpha + # cairo.FORMAT_ARGB32 uses pre-multiplied alpha + data[y][x][0] = int(x * alpha/255.0) # B + data[y][x][1] = int(y * alpha/255.0) # G + data[y][x][2] = 0 # R + data[y][x][3] = alpha # A surface = cairo.ImageSurface.create_for_data (data, cairo.FORMAT_ARGB32, width, height) ctx = cairo.Context(surface) -surface.write_to_png(dir_ + 'for_data2.png') +surface.write_to_png(fileName) +print "see %s output file" % fileName diff --git a/test/isurface_create_from_png.py b/test/isurface_create_from_png.py index 951acb3..129016d 100755 --- a/test/isurface_create_from_png.py +++ b/test/isurface_create_from_png.py @@ -1,37 +1,56 @@ #!/usr/bin/env python -# test cairo.ImageSurface.create_from_png() +'''test cairo.ImageSurface.create_from_png() and + cairo.Surface.write_to_png() +''' + +import os +import tempfile import cairo -surface = cairo.ImageSurface.create_from_png("/tmp/warpedtext.png") +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') + +inFileName = os.path.join(os.path.dirname(__file__), '..', 'examples', + 'cairo_snippets', 'data', 'romedalen.png') +surface = cairo.ImageSurface.create_from_png(inFileName) # write to filename -surface.write_to_png("/tmp/t1.png") +_, outFileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') +surface.write_to_png(outFileName) +print "see %s output file" % outFileName # write to file object -f2=file("/tmp/t2.png", "w") -surface.write_to_png(f2) -f2.close() +h, outFileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') +os.close(h) +f=file(outFileName, "w") +surface.write_to_png(f) +f.close() +print "see %s output file" % outFileName # write to object that has a "write" method import StringIO -buffer = StringIO.StringIO() -surface.write_to_png(buffer) -png_string = buffer.getvalue() -buffer.close() -f3=file("/tmp/t3.png", "w") -f3.write(png_string) -f3.close() +_, outFileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') +buf = StringIO.StringIO() +surface.write_to_png(buf) +png_string = buf.getvalue() +buf.close() +f=file(outFileName, "w") +f.write(png_string) +f.close() +print "see %s output file" % outFileName # write to object that has a "write" method +_, outFileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') import cStringIO -buffer = cStringIO.StringIO() -surface.write_to_png(buffer) -png_string = buffer.getvalue() -buffer.close() -f4=file("/tmp/t4.png", "w") -f4.write(png_string) -f4.close() +buf = cStringIO.StringIO() +surface.write_to_png(buf) +png_string = buf.getvalue() +buf.close() +f=file(outFileName, "w") +f.write(png_string) +f.close() +print "see %s output file" % outFileName # error test - to check the error message, should raise TypeError #surface.write_to_png(101) diff --git a/test/isurface_get_data.py b/test/isurface_get_data.py index c19a17e..f2662d4 100755 --- a/test/isurface_get_data.py +++ b/test/isurface_get_data.py @@ -2,11 +2,14 @@ """ Test ImageSurface.get_data() """ +import tempfile import cairo import numpy -dir_ = "/tmp/" +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') + w, h = 128, 128 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) @@ -25,7 +28,9 @@ ctx.close_path() ctx.set_source_rgb(0, 0, 0) # black ctx.set_line_width(15) ctx.stroke() -surface.write_to_png(dir_ + "get_data_test1.png") +_, outFileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') +surface.write_to_png(outFileName) +print "see %s output file" % outFileName # modify surface using numpy buf = surface.get_data() @@ -40,4 +45,6 @@ a = numpy.ndarray(shape=(w,h,4), dtype=numpy.uint8, buffer=buf) a[:,40,0] = 255 # byte 0 is blue on little-endian systems a[:,40,1] = 0 a[:,40,2] = 0 -surface.write_to_png(dir_ + "get_data_test2.png") +_, outFileName = tempfile.mkstemp(prefix='pycairo_', suffix='.png') +surface.write_to_png(outFileName) +print "see %s output file" % outFileName diff --git a/test/pygame-test1.py b/test/pygame-test1.py index 25871e5..bd96b88 100755 --- a/test/pygame-test1.py +++ b/test/pygame-test1.py @@ -11,21 +11,21 @@ import cairo import pygame def draw(surface): - x,y, radius = (250,250, 200) - ctx = cairo.Context(surface) - ctx.set_line_width(15) - ctx.arc(x, y, radius, 0, 2.0 * math.pi) - ctx.set_source_rgb(0.8, 0.8, 0.8) - ctx.fill_preserve() - ctx.set_source_rgb(1, 1, 1) - ctx.stroke() + x,y, radius = (250,250, 200) + ctx = cairo.Context(surface) + ctx.set_line_width(15) + ctx.arc(x, y, radius, 0, 2.0 * math.pi) + ctx.set_source_rgb(0.8, 0.8, 0.8) + ctx.fill_preserve() + ctx.set_source_rgb(1, 1, 1) + ctx.stroke() def input(events): - for event in events: - if event.type == pygame.QUIT: - sys.exit(0) - else: - print event + for event in events: + if event.type == pygame.QUIT: + sys.exit(0) + else: + print event Width, Height = 512, 512 @@ -45,7 +45,7 @@ screen.blit(image, (0,0)) pygame.display.flip() while True: - input(pygame.event.get()) + input(pygame.event.get()) """ diff --git a/test/pygame-test2.py b/test/pygame-test2.py index 9ebc1ae..bec32de 100755 --- a/test/pygame-test2.py +++ b/test/pygame-test2.py @@ -11,21 +11,21 @@ import cairo import pygame def draw(surface): - x,y, radius = (250,250, 200) - ctx = cairo.Context(surface) - ctx.set_line_width(15) - ctx.arc(x, y, radius, 0, 2.0 * math.pi) - ctx.set_source_rgb(0.8, 0.8, 0.8) - ctx.fill_preserve() - ctx.set_source_rgb(1, 1, 1) - ctx.stroke() + x,y, radius = (250,250, 200) + ctx = cairo.Context(surface) + ctx.set_line_width(15) + ctx.arc(x, y, radius, 0, 2.0 * math.pi) + ctx.set_source_rgb(0.8, 0.8, 0.8) + ctx.fill_preserve() + ctx.set_source_rgb(1, 1, 1) + ctx.stroke() def input(events): - for event in events: - if event.type == pygame.QUIT: - sys.exit(0) - else: - print event + for event in events: + if event.type == pygame.QUIT: + sys.exit(0) + else: + print event Width, Height = 512, 512 @@ -46,4 +46,4 @@ screen.blit(image, (0,0)) pygame.display.flip() while True: - input(pygame.event.get()) + input(pygame.event.get()) diff --git a/test/surface_create_for_stream.py b/test/surface_create_for_stream.py index 210badd..61997e0 100755 --- a/test/surface_create_for_stream.py +++ b/test/surface_create_for_stream.py @@ -13,19 +13,19 @@ import cairo class C(object): - """a file-like object (for testing), it simulates sys.stdout - """ - def __init__ (self): - self.closed = False + """a file-like object (for testing), it simulates sys.stdout + """ + def __init__ (self): + self.closed = False - def write(self, s): - """just echo to stdout, without newlines""" - if self.closed: - raise ValueError ("I/O operation on closed file") - sys.stdout.write (s) + def write(self, s): + """just echo to stdout, without newlines""" + if self.closed: + raise ValueError ("I/O operation on closed file") + sys.stdout.write(s) - def close(self): - self.closed = True + def close(self): + self.closed = True # a selection of possible args to surface.write_to_png() @@ -40,36 +40,36 @@ fo = file('/tmp/f.svg', 'w') WIDTH, HEIGHT = 256, 256 -#surface = cairo.PDFSurface (fo, WIDTH, HEIGHT) -#surface = cairo.PSSurface (fo, WIDTH, HEIGHT) -surface = cairo.SVGSurface (fo, WIDTH, HEIGHT) +#surface = cairo.PDFSurface(fo, WIDTH, HEIGHT) +#surface = cairo.PSSurface(fo, WIDTH, HEIGHT) +surface = cairo.SVGSurface(fo, WIDTH, HEIGHT) #sys.stdout.write ('1\n'); sys.stdout.flush() -ctx = cairo.Context (surface) +ctx = cairo.Context(surface) #del fo # test that 'fo' is referenced to keep it alive #gc.collect() #fo.close() # this should cause: ValueError: I/O operation on closed file -ctx.scale (WIDTH/1.0, HEIGHT/1.0) +ctx.scale(WIDTH/1.0, HEIGHT/1.0) -pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0) -pat.add_color_stop_rgba (1, 0, 0, 0, 1) -pat.add_color_stop_rgba (0, 1, 1, 1, 1) +pat = cairo.LinearGradient(0.0, 0.0, 0.0, 1.0) +pat.add_color_stop_rgba(1, 0, 0, 0, 1) +pat.add_color_stop_rgba(0, 1, 1, 1, 1) -ctx.rectangle (0,0,1,1) -ctx.set_source (pat) -ctx.fill () +ctx.rectangle(0,0,1,1) +ctx.set_source(pat) +ctx.fill() -pat = cairo.RadialGradient (0.45, 0.4, 0.1, +pat = cairo.RadialGradient(0.45, 0.4, 0.1, 0.4, 0.4, 0.5) -pat.add_color_stop_rgba (0, 1, 1, 1, 1) -pat.add_color_stop_rgba (1, 0, 0, 0, 1) +pat.add_color_stop_rgba(0, 1, 1, 1, 1) +pat.add_color_stop_rgba(1, 0, 0, 0, 1) -ctx.set_source (pat) -ctx.arc (0.5, 0.5, 0.3, 0, 2 * math.pi) -ctx.fill () +ctx.set_source(pat) +ctx.arc(0.5, 0.5, 0.3, 0, 2 * math.pi) +ctx.fill() ctx.show_page() surface.finish() diff --git a/test/surface_write_to_png.py b/test/surface_write_to_png.py index f4ba83b..61674f4 100755 --- a/test/surface_write_to_png.py +++ b/test/surface_write_to_png.py @@ -11,20 +11,24 @@ import StringIO import cairo +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') + + class C(object): - """a file-like object (for testing), it simulates sys.stdout - """ - def __init__(self): - self.closed = False + """a file-like object (for testing), it simulates sys.stdout + """ + def __init__(self): + self.closed = False - def write(self, s): - """just echo to stdout, without newlines""" - if self.closed: - raise ValueError("I/O operation on closed file") - sys.stdout.write(s) + def write(self, s): + """just echo to stdout, without newlines""" + if self.closed: + raise ValueError("I/O operation on closed file") + sys.stdout.write(s) - def close(self): - self.closed = True + def close(self): + self.closed = True WIDTH, HEIGHT = 256, 256 @@ -59,7 +63,7 @@ fo = file('/tmp/f.png', 'w') #fo = sys.stdout #fo = C() -fo.close() # this should cause: ValueError: I/O operation on closed file +#fo.close() # this should cause: ValueError: I/O operation on closed file surface.write_to_png(fo) # for testing StringIO: get data and write to file -- cgit v1.2.1