[Checkins] SVN: zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging- Explicitly close files after writing to them.
Marius Gedminas
cvs-admin at zope.org
Fri Feb 8 13:20:46 UTC 2013
Log message for revision 129224:
Explicitly close files after writing to them.
This fixes nondeterministic test failures I've seen on Python 3.3
(sometimes), as well as on PyPy (always).
Changed:
U zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-import-failure.test
U zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test
-=-
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-import-failure.test
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-import-failure.test 2013-02-08 13:20:43 UTC (rev 129223)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-import-failure.test 2013-02-08 13:20:45 UTC (rev 129224)
@@ -6,7 +6,11 @@
>>> tdir = tempfile.mkdtemp()
>>> dir = os.path.join(tdir, 'TESTS-DIR')
>>> os.mkdir(dir)
- >>> written = open(os.path.join(dir, 'tests.py'), 'w').write(
+ >>> def write_file(filename, body):
+ ... with open(os.path.join(dir, filename), 'w') as f:
+ ... f.write(body)
+
+ >>> write_file('tests.py',
... '''
... impot doctest
... ''')
@@ -40,7 +44,7 @@
>>> sys.stdin = Input('c')
- >>> written = open(os.path.join(dir, 'tests2.py'), 'w').write(
+ >>> write_file('tests2.py',
... '''
... def test_suite():
... return None
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test 2013-02-08 13:20:43 UTC (rev 129223)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test 2013-02-08 13:20:45 UTC (rev 129224)
@@ -5,7 +5,11 @@
>>> tdir = tempfile.mkdtemp()
>>> dir = os.path.join(tdir, 'TESTS-DIR')
>>> os.mkdir(dir)
- >>> written = open(os.path.join(dir, 'tests.py'), 'w').write(
+ >>> def write_file(filename, body):
+ ... with open(os.path.join(dir, filename), 'w') as f:
+ ... f.write(body)
+
+ >>> write_file('tests.py',
... '''
... import doctest
...
@@ -14,7 +18,7 @@
... def setUp(self):
... x = 1
... raise ValueError
- ...
+ ...
... def a_test():
... """
... >>> None
@@ -25,7 +29,7 @@
... return suite
...
... ''')
-
+
>>> class Input:
... def __init__(self, src):
... self.lines = src.split('\n')
@@ -59,7 +63,7 @@
>>> sys.stdin = Input('p x\nc')
- >>> written = open(os.path.join(dir, 'tests2.py'), 'w').write(
+ >>> write_file('tests2.py',
... '''
... import doctest, unittest
...
More information about the checkins
mailing list