bpo-40275: Use new test.support helper submodules in tests (GH-21169)
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index aced876..0162424 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1,6 +1,9 @@
import unittest
from unittest import mock
from test import support
+from test.support import import_helper
+from test.support import os_helper
+from test.support import warnings_helper
import subprocess
import sys
import signal
@@ -20,7 +23,7 @@
import gc
import textwrap
import json
-from test.support import FakePath
+from test.support.os_helper import FakePath
try:
import _testcapi
@@ -357,7 +360,7 @@
# Normalize an expected cwd (for Tru64 support).
# We can't use os.path.realpath since it doesn't expand Tru64 {memb}
# strings. See bug #1063571.
- with support.change_cwd(cwd):
+ with os_helper.change_cwd(cwd):
return os.getcwd()
# For use in the test_cwd* tests below.
@@ -406,7 +409,7 @@
# is relative.
python_dir, python_base = self._split_python_path()
rel_python = os.path.join(os.curdir, python_base)
- with support.temp_cwd() as wrong_dir:
+ with os_helper.temp_cwd() as wrong_dir:
# Before calling with the correct cwd, confirm that the call fails
# without cwd and with the wrong cwd.
self.assertRaises(FileNotFoundError, subprocess.Popen,
@@ -423,7 +426,7 @@
python_dir, python_base = self._split_python_path()
rel_python = os.path.join(os.curdir, python_base)
doesntexist = "somethingyoudonthave"
- with support.temp_cwd() as wrong_dir:
+ with os_helper.temp_cwd() as wrong_dir:
# Before calling with the correct cwd, confirm that the call fails
# without cwd and with the wrong cwd.
self.assertRaises(FileNotFoundError, subprocess.Popen,
@@ -441,7 +444,7 @@
python_dir, python_base = self._split_python_path()
abs_python = os.path.join(python_dir, python_base)
rel_python = os.path.join(os.curdir, python_base)
- with support.temp_dir() as wrong_dir:
+ with os_helper.temp_dir() as wrong_dir:
# Before calling with an absolute path, confirm that using a
# relative path fails.
self.assertRaises(FileNotFoundError, subprocess.Popen,
@@ -1052,7 +1055,7 @@
try:
for i in range(max_handles):
try:
- tmpfile = os.path.join(tmpdir, support.TESTFN)
+ tmpfile = os.path.join(tmpdir, os_helper.TESTFN)
handles.append(os.open(tmpfile, os.O_WRONLY|os.O_CREAT))
except OSError as e:
if e.errno != errno.EMFILE:
@@ -2881,7 +2884,7 @@
def test_select_unbuffered(self):
# Issue #11459: bufsize=0 should really set the pipes as
# unbuffered (and therefore let select() work properly).
- select = support.import_module("select")
+ select = import_helper.import_module("select")
p = subprocess.Popen([sys.executable, "-c",
'import sys;'
'sys.stdout.write("apple")'],
@@ -2909,7 +2912,7 @@
self.addCleanup(p.stderr.close)
ident = id(p)
pid = p.pid
- with support.check_warnings(('', ResourceWarning)):
+ with warnings_helper.check_warnings(('', ResourceWarning)):
p = None
if mswindows:
@@ -2934,7 +2937,7 @@
self.addCleanup(p.stderr.close)
ident = id(p)
pid = p.pid
- with support.check_warnings(('', ResourceWarning)):
+ with warnings_helper.check_warnings(('', ResourceWarning)):
p = None
os.kill(pid, signal.SIGKILL)
@@ -3288,7 +3291,8 @@
self.assertIn(b"OSError", stderr)
# Check for a warning due to using handle_list and close_fds=False
- with support.check_warnings((".*overriding close_fds", RuntimeWarning)):
+ with warnings_helper.check_warnings((".*overriding close_fds",
+ RuntimeWarning)):
startupinfo = subprocess.STARTUPINFO()
startupinfo.lpAttributeList = {"handle_list": handles[:]}
p = subprocess.Popen([sys.executable, "-c",