diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-20 07:36:55 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-20 07:36:55 (GMT) |
commit | 0b72ae8e78dd514d4d6d6f38e4948678fcb634fe (patch) | |
tree | 53d1a1dde9ceacffabf3f94a2bbf1c6ca9bbd522 | |
parent | e789038e0d2740e226aa34ec36428bdab241fc71 (diff) | |
download | cpython-0b72ae8e78dd514d4d6d6f38e4948678fcb634fe.zip cpython-0b72ae8e78dd514d4d6d6f38e4948678fcb634fe.tar.gz cpython-0b72ae8e78dd514d4d6d6f38e4948678fcb634fe.tar.bz2 |
Create a file in SizeofTest only if needed.
-rw-r--r-- | 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 index 4afb780..c68b50f 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -484,11 +484,6 @@ class SizeofTest(unittest.TestCase): 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 @@ class SizeofTest(unittest.TestCase): # 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 @@ class SizeofTest(unittest.TestCase): 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: |