Mercurial > genshi > mirror
changeset 868:eb80cbd8e4fe trunk
Fix the unit test for execution of statements containing with statements so that it also works on Windows. Thanks to cboos for the patch.
author | cmlenz |
---|---|
date | Sat, 28 Nov 2009 15:37:30 +0000 |
parents | 82ba3198d913 |
children | 013623773357 |
files | genshi/template/tests/eval.py |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/template/tests/eval.py +++ b/genshi/template/tests/eval.py @@ -16,7 +16,7 @@ import pickle from StringIO import StringIO import sys -from tempfile import NamedTemporaryFile +from tempfile import mkstemp import unittest from genshi.core import Markup @@ -787,19 +787,24 @@ if sys.version_info >= (2, 5): def test_with_statement(self): - f = NamedTemporaryFile() - f.write('foo\nbar\n') - f.seek(0) + fd, path = mkstemp() + f = os.fdopen(fd, "w") + try: + f.write('foo\nbar\n') + f.seek(0) + f.close() - d = {'path': f.name} - suite = Suite("""from __future__ import with_statement + d = {'path': path} + suite = Suite("""from __future__ import with_statement lines = [] with open(path) as file: for line in file: lines.append(line) """) - suite.execute(d) - self.assertEqual(['foo\n', 'bar\n'], d['lines']) + suite.execute(d) + self.assertEqual(['foo\n', 'bar\n'], d['lines']) + finally: + os.remove(path) def test_yield_expression(self): d = {}