# HG changeset patch # User cmlenz # Date 1259422650 0 # Node ID 9309530ee279e286f3cf923ef2534a19898a6282 # Parent efc03d0719f3bcca04cc3e71803ab829062c068d Fix the unit test for execution of statements containing with statements so that it also works on Windows. Thanks to cboos for the patch. diff --git a/genshi/template/tests/eval.py b/genshi/template/tests/eval.py --- 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 = {}