aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_multiprocessing_main_handling.py
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-07-09 21:25:10 +0800
committerGitHub <noreply@github.com>2020-07-09 15:25:10 +0200
commit96a6a6d42be272a27562d98549bbffc0d1854669 (patch)
tree9c4fc12729aa2accce4ca953a6431acec87cf542 /Lib/test/test_multiprocessing_main_handling.py
parent61bb24a270d15106decb1c7983bf4c2831671a75 (diff)
downloadcpython-96a6a6d42be272a27562d98549bbffc0d1854669.tar.gz
cpython-96a6a6d42be272a27562d98549bbffc0d1854669.zip
bpo-40275: Use new test.support helper submodules in tests (GH-21412)
Diffstat (limited to 'Lib/test/test_multiprocessing_main_handling.py')
-rw-r--r--Lib/test/test_multiprocessing_main_handling.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/Lib/test/test_multiprocessing_main_handling.py b/Lib/test/test_multiprocessing_main_handling.py
index be1ff10e03a..510d8d3a759 100644
--- a/Lib/test/test_multiprocessing_main_handling.py
+++ b/Lib/test/test_multiprocessing_main_handling.py
@@ -1,7 +1,8 @@
# tests __main__ module handling in multiprocessing
from test import support
+from test.support import import_helper
# Skip tests if _multiprocessing wasn't built.
-support.import_module('_multiprocessing')
+import_helper.import_module('_multiprocessing')
import importlib
import importlib.machinery
@@ -11,6 +12,7 @@ import os
import os.path
import py_compile
+from test.support import os_helper
from test.support.script_helper import (
make_pkg, make_script, make_zip_pkg, make_zip_script,
assert_python_ok)
@@ -167,12 +169,12 @@ class MultiProcessingCmdLineMixin():
self._check_output(script_name, rc, out, err)
def test_basic_script(self):
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
self._check_script(script_name)
def test_basic_script_no_suffix(self):
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script',
omit_suffix=True)
self._check_script(script_name)
@@ -183,7 +185,7 @@ class MultiProcessingCmdLineMixin():
# a workaround for that case
# See https://github.com/ipython/ipython/issues/4698
source = test_source_main_skipped_in_children
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'ipython',
source=source)
self._check_script(script_name)
@@ -193,33 +195,33 @@ class MultiProcessingCmdLineMixin():
self._check_script(script_no_suffix)
def test_script_compiled(self):
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- pyc_file = support.make_legacy_pyc(script_name)
+ pyc_file = import_helper.make_legacy_pyc(script_name)
self._check_script(pyc_file)
def test_directory(self):
source = self.main_in_children_source
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__',
source=source)
self._check_script(script_dir)
def test_directory_compiled(self):
source = self.main_in_children_source
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__',
source=source)
py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- pyc_file = support.make_legacy_pyc(script_name)
+ pyc_file = import_helper.make_legacy_pyc(script_name)
self._check_script(script_dir)
def test_zipfile(self):
source = self.main_in_children_source
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__',
source=source)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
@@ -227,7 +229,7 @@ class MultiProcessingCmdLineMixin():
def test_zipfile_compiled(self):
source = self.main_in_children_source
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__',
source=source)
compiled_name = py_compile.compile(script_name, doraise=True)
@@ -235,7 +237,7 @@ class MultiProcessingCmdLineMixin():
self._check_script(zip_name)
def test_module_in_package(self):
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, 'check_sibling')
@@ -244,20 +246,20 @@ class MultiProcessingCmdLineMixin():
self._check_script(launch_name)
def test_module_in_package_in_zipfile(self):
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script', zip_name)
self._check_script(launch_name)
def test_module_in_subpackage_in_zipfile(self):
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2)
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.test_pkg.script', zip_name)
self._check_script(launch_name)
def test_package(self):
source = self.main_in_children_source
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, '__main__',
@@ -267,14 +269,14 @@ class MultiProcessingCmdLineMixin():
def test_package_compiled(self):
source = self.main_in_children_source
- with support.temp_dir() as script_dir:
+ with os_helper.temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, '__main__',
source=source)
compiled_name = py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- pyc_file = support.make_legacy_pyc(script_name)
+ pyc_file = import_helper.make_legacy_pyc(script_name)
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
self._check_script(launch_name)