diff options
author | Brett Cannon <brett@python.org> | 2011-08-05 04:34:52 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2011-08-05 04:34:52 (GMT) |
commit | a4265546f9d457ff61e7e4d3fb6d6b3cc54a09d2 (patch) | |
tree | 6c8eebd13f37ab9b6592469c293321ac67a9e658 /Lib/test/test_sysconfig.py | |
parent | 087a2a951c6193074dfd05d3d777f47bef5da8e4 (diff) | |
download | cpython-a4265546f9d457ff61e7e4d3fb6d6b3cc54a09d2.zip cpython-a4265546f9d457ff61e7e4d3fb6d6b3cc54a09d2.tar.gz cpython-a4265546f9d457ff61e7e4d3fb6d6b3cc54a09d2.tar.bz2 |
Explicitly close a file to stop raising a ResourceWarning.
Diffstat (limited to 'Lib/test/test_sysconfig.py')
-rw-r--r-- | Lib/test/test_sysconfig.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 96f75f2..241af8f 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -306,19 +306,20 @@ class TestSysConfig(unittest.TestCase): env = os.environ.copy() env['MACOSX_DEPLOYMENT_TARGET'] = '10.1' - p = subprocess.Popen([ - sys.executable, '-c', - 'import sysconfig; print(sysconfig.get_platform())', - ], - stdout=subprocess.PIPE, - stderr=open('/dev/null'), - env=env) - test_platform = p.communicate()[0].strip() - test_platform = test_platform.decode('utf-8') - status = p.wait() + with open('/dev/null') as dev_null: + p = subprocess.Popen([ + sys.executable, '-c', + 'import sysconfig; print(sysconfig.get_platform())', + ], + stdout=subprocess.PIPE, + stderr=dev_null, + env=env) + test_platform = p.communicate()[0].strip() + test_platform = test_platform.decode('utf-8') + status = p.wait() - self.assertEqual(status, 0) - self.assertEqual(my_platform, test_platform) + self.assertEqual(status, 0) + self.assertEqual(my_platform, test_platform) class MakefileTests(unittest.TestCase): |