aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-08-07 23:18:38 +0800
committerGitHub <noreply@github.com>2020-08-07 17:18:38 +0200
commit598a951844122678de2596dbc1e0e09e2be65fd2 (patch)
tree23e7f7765fd015e838382e443f39269a2745fbc4 /Lib/test/_test_multiprocessing.py
parent46e19b61d31ba99f049258efa4ff1334856a3643 (diff)
downloadcpython-598a951844122678de2596dbc1e0e09e2be65fd2.tar.gz
cpython-598a951844122678de2596dbc1e0e09e2be65fd2.zip
bpo-40275: Use new test.support helper submodules in tests (GH-21764)
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index bde102ae2e0..58663c02002 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -28,8 +28,10 @@ import test.support.script_helper
from test import support
from test.support import hashlib_helper
from test.support import import_helper
+from test.support import os_helper
from test.support import socket_helper
from test.support import threading_helper
+from test.support import warnings_helper
# Skip tests if _multiprocessing wasn't built.
@@ -615,7 +617,7 @@ class _TestProcess(BaseTestCase):
@classmethod
def _test_child_fd_inflation(self, evt, q):
- q.put(test.support.fd_count())
+ q.put(os_helper.fd_count())
evt.wait()
def test_child_fd_inflation(self):
@@ -819,8 +821,8 @@ class _TestSubclassingProcess(BaseTestCase):
if self.TYPE == "threads":
self.skipTest('test not appropriate for {}'.format(self.TYPE))
- testfn = test.support.TESTFN
- self.addCleanup(test.support.unlink, testfn)
+ testfn = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, testfn)
proc = self.Process(target=self._test_stderr_flush, args=(testfn,))
proc.start()
proc.join()
@@ -849,8 +851,8 @@ class _TestSubclassingProcess(BaseTestCase):
if self.TYPE == 'threads':
self.skipTest('test not appropriate for {}'.format(self.TYPE))
- testfn = test.support.TESTFN
- self.addCleanup(test.support.unlink, testfn)
+ testfn = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, testfn)
for reason in (
[1, 2, 3],
@@ -1114,7 +1116,7 @@ class _TestQueue(BaseTestCase):
close_queue(queue)
def test_no_import_lock_contention(self):
- with test.support.temp_cwd():
+ with os_helper.temp_cwd():
module_name = 'imported_by_an_imported_module'
with open(module_name + '.py', 'w') as f:
f.write("""if 1:
@@ -1127,7 +1129,7 @@ class _TestQueue(BaseTestCase):
del q
""")
- with test.support.DirsOnSysPath(os.getcwd()):
+ with import_helper.DirsOnSysPath(os.getcwd()):
try:
__import__(module_name)
except pyqueue.Empty:
@@ -2688,8 +2690,8 @@ class _TestPool(BaseTestCase):
# force state to RUN to emit ResourceWarning in __del__()
pool._state = multiprocessing.pool.RUN
- with support.check_warnings(('unclosed running multiprocessing pool',
- ResourceWarning)):
+ with warnings_helper.check_warnings(
+ ('unclosed running multiprocessing pool', ResourceWarning)):
pool = None
support.gc_collect()
@@ -3199,14 +3201,14 @@ class _TestConnection(BaseTestCase):
p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
p.daemon = True
p.start()
- self.addCleanup(test.support.unlink, test.support.TESTFN)
- with open(test.support.TESTFN, "wb") as f:
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ with open(os_helper.TESTFN, "wb") as f:
fd = f.fileno()
if msvcrt:
fd = msvcrt.get_osfhandle(fd)
reduction.send_handle(conn, fd, p.pid)
p.join()
- with open(test.support.TESTFN, "rb") as f:
+ with open(os_helper.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"foo")
@unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
@@ -3225,8 +3227,8 @@ class _TestConnection(BaseTestCase):
p = self.Process(target=self._writefd, args=(child_conn, b"bar", True))
p.daemon = True
p.start()
- self.addCleanup(test.support.unlink, test.support.TESTFN)
- with open(test.support.TESTFN, "wb") as f:
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ with open(os_helper.TESTFN, "wb") as f:
fd = f.fileno()
for newfd in range(256, MAXFD):
if not self._is_fd_assigned(newfd):
@@ -3239,7 +3241,7 @@ class _TestConnection(BaseTestCase):
finally:
os.close(newfd)
p.join()
- with open(test.support.TESTFN, "rb") as f:
+ with open(os_helper.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"bar")
@classmethod