Skip to content

Commit 075bbb1

Browse files
committed
utilize subprocess.DEVNULL
1 parent a3d6538 commit 075bbb1

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

Lib/test/test_sysconfig.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,13 @@ def test_platform_in_subprocess(self):
305305
if 'MACOSX_DEPLOYMENT_TARGET' in env:
306306
del env['MACOSX_DEPLOYMENT_TARGET']
307307

308-
with open('/dev/null', 'w') as devnull_fp:
309-
p = subprocess.Popen([
310-
sys.executable, '-c',
311-
'import sysconfig; print(sysconfig.get_platform())',
312-
],
313-
stdout=subprocess.PIPE,
314-
stderr=devnull_fp,
315-
env=env)
308+
p = subprocess.Popen([
309+
sys.executable, '-c',
310+
'import sysconfig; print(sysconfig.get_platform())',
311+
],
312+
stdout=subprocess.PIPE,
313+
stderr=subprocess.DEVNULL,
314+
env=env)
316315
test_platform = p.communicate()[0].strip()
317316
test_platform = test_platform.decode('utf-8')
318317
status = p.wait()
@@ -325,20 +324,19 @@ def test_platform_in_subprocess(self):
325324
env = os.environ.copy()
326325
env['MACOSX_DEPLOYMENT_TARGET'] = '10.1'
327326

328-
with open('/dev/null') as dev_null:
329-
p = subprocess.Popen([
330-
sys.executable, '-c',
331-
'import sysconfig; print(sysconfig.get_platform())',
332-
],
333-
stdout=subprocess.PIPE,
334-
stderr=dev_null,
335-
env=env)
336-
test_platform = p.communicate()[0].strip()
337-
test_platform = test_platform.decode('utf-8')
338-
status = p.wait()
339-
340-
self.assertEqual(status, 0)
341-
self.assertEqual(my_platform, test_platform)
327+
p = subprocess.Popen([
328+
sys.executable, '-c',
329+
'import sysconfig; print(sysconfig.get_platform())',
330+
],
331+
stdout=subprocess.PIPE,
332+
stderr=subprocess.DEVNULL,
333+
env=env)
334+
test_platform = p.communicate()[0].strip()
335+
test_platform = test_platform.decode('utf-8')
336+
status = p.wait()
337+
338+
self.assertEqual(status, 0)
339+
self.assertEqual(my_platform, test_platform)
342340

343341
def test_srcdir(self):
344342
# See Issues #15322, #15364.

0 commit comments

Comments
 (0)