Edgewall Software

Ticket #357: fix-test_with_statement-r1090.patch

File fix-test_with_statement-r1090.patch, 1.2 KB (added by cboos, 14 years ago)

Fix the failing test by using tempfile.mkstemp

  • genshi/template/tests/eval.py

    Follow-up to r1090, fix test_with_statement test on windows, where `NamedTemporaryFile` can't be used in this situation.
    
    Closes #357.
    
    diff --git a/genshi/template/tests/eval.py b/genshi/template/tests/eval.py
    a b  
    1616import pickle
    1717from StringIO import StringIO
    1818import sys
    19 from tempfile import NamedTemporaryFile
     19from tempfile import mkstemp
    2020import unittest
    2121
    2222from genshi.core import Markup
     
    787787
    788788    if sys.version_info >= (2, 5):
    789789        def test_with_statement(self):
    790             f = NamedTemporaryFile()
     790            fd, path = mkstemp()
     791            f = os.fdopen(fd, "w")
    791792            f.write('foo\nbar\n')
    792793            f.seek(0)
     794            f.close()
    793795
    794             d = {'path': f.name}
     796            d = {'path': path}
    795797            suite = Suite("""from __future__ import with_statement
    796798lines = []
    797799with open(path) as file:
     
    800802""")
    801803            suite.execute(d)
    802804            self.assertEqual(['foo\n', 'bar\n'], d['lines'])
     805            os.remove(path)
    803806
    804807        def test_yield_expression(self):
    805808            d = {}