cpython (2.7): Create a file in SizeofTest only if needed.
https://hg.python.org/cpython/rev/f3a095ad52fe changeset: 99637:f3a095ad52fe branch: 2.7 parent: 99635:ab97ff838e11 user: Serhiy Storchaka <storchaka@gmail.com> date: Sun Dec 20 09:36:55 2015 +0200 summary: Create a file in SizeofTest only if needed. files: Lib/test/test_sys.py | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -484,11 +484,6 @@ self.longdigit = sys.long_info.sizeof_digit import _testcapi self.gc_headsize = _testcapi.SIZEOF_PYGC_HEAD - self.file = open(test.test_support.TESTFN, 'wb') - - def tearDown(self): - self.file.close() - test.test_support.unlink(test.test_support.TESTFN) check_sizeof = test.test_support.check_sizeof @@ -613,7 +608,12 @@ # enumerate check(enumerate([]), size('l3P')) # file - check(self.file, size('4P2i4P3i3P3i')) + f = file(test.test_support.TESTFN, 'wb') + try: + check(f, size('4P2i4P3i3P3i')) + finally: + f.close() + test.test_support.unlink(test.test_support.TESTFN) # float check(float(0), size('d')) # sys.floatinfo @@ -793,7 +793,12 @@ check(_ast.AST(), size('')) # imp.NullImporter import imp - check(imp.NullImporter(self.file.name), size('')) + f = open(test.test_support.TESTFN, 'wb') + try: + check(imp.NullImporter(f.name), size('')) + finally: + f.close() + test.test_support.unlink(test.test_support.TESTFN) try: raise TypeError except TypeError: -- Repository URL: https://hg.python.org/cpython
participants (1)
-
serhiy.storchaka