Skip to content

Commit

Permalink
utilize subprocess.DEVNULL
Browse files Browse the repository at this point in the history
  • Loading branch information
pjenvey committed Oct 1, 2012
1 parent a3d6538 commit 075bbb1
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,13 @@ def test_platform_in_subprocess(self):
if 'MACOSX_DEPLOYMENT_TARGET' in env:
del env['MACOSX_DEPLOYMENT_TARGET']

with open('/dev/null', 'w') as devnull_fp:
p = subprocess.Popen([
sys.executable, '-c',
'import sysconfig; print(sysconfig.get_platform())',
],
stdout=subprocess.PIPE,
stderr=devnull_fp,
env=env)
p = subprocess.Popen([
sys.executable, '-c',
'import sysconfig; print(sysconfig.get_platform())',
],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
env=env)
test_platform = p.communicate()[0].strip()
test_platform = test_platform.decode('utf-8')
status = p.wait()
Expand All @@ -325,20 +324,19 @@ def test_platform_in_subprocess(self):
env = os.environ.copy()
env['MACOSX_DEPLOYMENT_TARGET'] = '10.1'

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)
p = subprocess.Popen([
sys.executable, '-c',
'import sysconfig; print(sysconfig.get_platform())',
],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
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)

def test_srcdir(self):
# See Issues #15322, #15364.
Expand Down

0 comments on commit 075bbb1

Please sign in to comment.