diff -r f0a00ee094ff -r 8711b188514a Lib/test/_test_multiprocessing.py --- a/Lib/test/_test_multiprocessing.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/_test_multiprocessing.py Thu Apr 16 17:08:37 2015 -0700 @@ -19,7 +19,7 @@ import struct import operator import test.support -import test.script_helper +import test.support.script_helper # Skip tests if _multiprocessing wasn't built. @@ -3477,11 +3477,11 @@ sm = multiprocessing.get_start_method() name = os.path.join(os.path.dirname(__file__), 'mp_fork_bomb.py') if sm != 'fork': - rc, out, err = test.script_helper.assert_python_failure(name, sm) + rc, out, err = test.support.script_helper.assert_python_failure(name, sm) self.assertEqual(out, b'') self.assertIn(b'RuntimeError', err) else: - rc, out, err = test.script_helper.assert_python_ok(name, sm) + rc, out, err = test.support.script_helper.assert_python_ok(name, sm) self.assertEqual(out.rstrip(), b'123') self.assertEqual(err, b'') diff -r f0a00ee094ff -r 8711b188514a Lib/test/script_helper.py --- a/Lib/test/script_helper.py Tue Apr 14 16:14:25 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -# Common utility functions used by various script execution tests -# e.g. test_cmd_line, test_cmd_line_script and test_runpy - -import collections -import importlib -import sys -import os -import os.path -import tempfile -import subprocess -import py_compile -import contextlib -import shutil -import zipfile - -from importlib.util import source_from_cache -from test.support import make_legacy_pyc, strip_python_stderr, temp_dir - - -# Cached result of the expensive test performed in the function below. -__cached_interp_requires_environment = None - -def interpreter_requires_environment(): - """ - Returns True if our sys.executable interpreter requires environment - variables in order to be able to run at all. - - This is designed to be used with @unittest.skipIf() to annotate tests - that need to use an assert_python*() function to launch an isolated - mode (-I) or no environment mode (-E) sub-interpreter process. - - A normal build & test does not run into this situation but it can happen - when trying to run the standard library test suite from an interpreter that - doesn't have an obvious home with Python's current home finding logic. - - Setting PYTHONHOME is one way to get most of the testsuite to run in that - situation. PYTHONPATH or PYTHONUSERSITE are other common environment - variables that might impact whether or not the interpreter can start. - """ - global __cached_interp_requires_environment - if __cached_interp_requires_environment is None: - # Try running an interpreter with -E to see if it works or not. - try: - subprocess.check_call([sys.executable, '-E', - '-c', 'import sys; sys.exit(0)']) - except subprocess.CalledProcessError: - __cached_interp_requires_environment = True - else: - __cached_interp_requires_environment = False - - return __cached_interp_requires_environment - - -_PythonRunResult = collections.namedtuple("_PythonRunResult", - ("rc", "out", "err")) - - -# Executing the interpreter in a subprocess -def run_python_until_end(*args, **env_vars): - env_required = interpreter_requires_environment() - if '__isolated' in env_vars: - isolated = env_vars.pop('__isolated') - else: - isolated = not env_vars and not env_required - cmd_line = [sys.executable, '-X', 'faulthandler'] - if isolated: - # isolated mode: ignore Python environment variables, ignore user - # site-packages, and don't add the current directory to sys.path - cmd_line.append('-I') - elif not env_vars and not env_required: - # ignore Python environment variables - cmd_line.append('-E') - # Need to preserve the original environment, for in-place testing of - # shared library builds. - env = os.environ.copy() - # But a special flag that can be set to override -- in this case, the - # caller is responsible to pass the full environment. - if env_vars.pop('__cleanenv', None): - env = {} - env.update(env_vars) - cmd_line.extend(args) - p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env) - try: - out, err = p.communicate() - finally: - subprocess._cleanup() - p.stdout.close() - p.stderr.close() - rc = p.returncode - err = strip_python_stderr(err) - return _PythonRunResult(rc, out, err), cmd_line - -def _assert_python(expected_success, *args, **env_vars): - res, cmd_line = run_python_until_end(*args, **env_vars) - if (res.rc and expected_success) or (not res.rc and not expected_success): - # Limit to 80 lines to ASCII characters - maxlen = 80 * 100 - out, err = res.out, res.err - if len(out) > maxlen: - out = b'(... truncated stdout ...)' + out[-maxlen:] - if len(err) > maxlen: - err = b'(... truncated stderr ...)' + err[-maxlen:] - out = out.decode('ascii', 'replace').rstrip() - err = err.decode('ascii', 'replace').rstrip() - raise AssertionError("Process return code is %d\n" - "command line: %r\n" - "\n" - "stdout:\n" - "---\n" - "%s\n" - "---\n" - "\n" - "stderr:\n" - "---\n" - "%s\n" - "---" - % (res.rc, cmd_line, - out, - err)) - return res - -def assert_python_ok(*args, **env_vars): - """ - Assert that running the interpreter with `args` and optional environment - variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, - stderr) tuple. - - If the __cleanenv keyword is set, env_vars is used a fresh environment. - - Python is started in isolated mode (command line option -I), - except if the __isolated keyword is set to False. - """ - return _assert_python(True, *args, **env_vars) - -def assert_python_failure(*args, **env_vars): - """ - Assert that running the interpreter with `args` and optional environment - variables `env_vars` fails (rc != 0) and return a (return code, stdout, - stderr) tuple. - - See assert_python_ok() for more options. - """ - return _assert_python(False, *args, **env_vars) - -def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw): - """Run a Python subprocess with the given arguments. - - kw is extra keyword args to pass to subprocess.Popen. Returns a Popen - object. - """ - cmd_line = [sys.executable, '-E'] - cmd_line.extend(args) - # Under Fedora (?), GNU readline can output junk on stderr when initialized, - # depending on the TERM setting. Setting TERM=vt100 is supposed to disable - # that. References: - # - http://reinout.vanrees.org/weblog/2009/08/14/readline-invisible-character-hack.html - # - http://stackoverflow.com/questions/15760712/python-readline-module-prints-escape-character-during-import - # - http://lists.gnu.org/archive/html/bug-readline/2007-08/msg00004.html - env = kw.setdefault('env', dict(os.environ)) - env['TERM'] = 'vt100' - return subprocess.Popen(cmd_line, stdin=subprocess.PIPE, - stdout=stdout, stderr=stderr, - **kw) - -def kill_python(p): - """Run the given Popen process until completion and return stdout.""" - p.stdin.close() - data = p.stdout.read() - p.stdout.close() - # try to cleanup the child so we don't appear to leak when running - # with regrtest -R. - p.wait() - subprocess._cleanup() - return data - -def make_script(script_dir, script_basename, source, omit_suffix=False): - script_filename = script_basename - if not omit_suffix: - script_filename += os.extsep + 'py' - script_name = os.path.join(script_dir, script_filename) - # The script should be encoded to UTF-8, the default string encoding - script_file = open(script_name, 'w', encoding='utf-8') - script_file.write(source) - script_file.close() - importlib.invalidate_caches() - return script_name - -def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None): - zip_filename = zip_basename+os.extsep+'zip' - zip_name = os.path.join(zip_dir, zip_filename) - zip_file = zipfile.ZipFile(zip_name, 'w') - if name_in_zip is None: - parts = script_name.split(os.sep) - if len(parts) >= 2 and parts[-2] == '__pycache__': - legacy_pyc = make_legacy_pyc(source_from_cache(script_name)) - name_in_zip = os.path.basename(legacy_pyc) - script_name = legacy_pyc - else: - name_in_zip = os.path.basename(script_name) - zip_file.write(script_name, name_in_zip) - zip_file.close() - #if test.support.verbose: - # zip_file = zipfile.ZipFile(zip_name, 'r') - # print 'Contents of %r:' % zip_name - # zip_file.printdir() - # zip_file.close() - return zip_name, os.path.join(zip_name, name_in_zip) - -def make_pkg(pkg_dir, init_source=''): - os.mkdir(pkg_dir) - make_script(pkg_dir, '__init__', init_source) - -def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, - source, depth=1, compiled=False): - unlink = [] - init_name = make_script(zip_dir, '__init__', '') - unlink.append(init_name) - init_basename = os.path.basename(init_name) - script_name = make_script(zip_dir, script_basename, source) - unlink.append(script_name) - if compiled: - init_name = py_compile.compile(init_name, doraise=True) - script_name = py_compile.compile(script_name, doraise=True) - unlink.extend((init_name, script_name)) - pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)] - script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name)) - zip_filename = zip_basename+os.extsep+'zip' - zip_name = os.path.join(zip_dir, zip_filename) - zip_file = zipfile.ZipFile(zip_name, 'w') - for name in pkg_names: - init_name_in_zip = os.path.join(name, init_basename) - zip_file.write(init_name, init_name_in_zip) - zip_file.write(script_name, script_name_in_zip) - zip_file.close() - for name in unlink: - os.unlink(name) - #if test.support.verbose: - # zip_file = zipfile.ZipFile(zip_name, 'r') - # print 'Contents of %r:' % zip_name - # zip_file.printdir() - # zip_file.close() - return zip_name, os.path.join(zip_name, script_name_in_zip) diff -r f0a00ee094ff -r 8711b188514a Lib/test/support/script_helper.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/support/script_helper.py Thu Apr 16 17:08:37 2015 -0700 @@ -0,0 +1,241 @@ +# Common utility functions used by various script execution tests +# e.g. test_cmd_line, test_cmd_line_script and test_runpy + +import collections +import importlib +import sys +import os +import os.path +import subprocess +import py_compile +import zipfile + +from importlib.util import source_from_cache +from test.support import make_legacy_pyc, strip_python_stderr + + +# Cached result of the expensive test performed in the function below. +__cached_interp_requires_environment = None + +def interpreter_requires_environment(): + """ + Returns True if our sys.executable interpreter requires environment + variables in order to be able to run at all. + + This is designed to be used with @unittest.skipIf() to annotate tests + that need to use an assert_python*() function to launch an isolated + mode (-I) or no environment mode (-E) sub-interpreter process. + + A normal build & test does not run into this situation but it can happen + when trying to run the standard library test suite from an interpreter that + doesn't have an obvious home with Python's current home finding logic. + + Setting PYTHONHOME is one way to get most of the testsuite to run in that + situation. PYTHONPATH or PYTHONUSERSITE are other common environment + variables that might impact whether or not the interpreter can start. + """ + global __cached_interp_requires_environment + if __cached_interp_requires_environment is None: + # Try running an interpreter with -E to see if it works or not. + try: + subprocess.check_call([sys.executable, '-E', + '-c', 'import sys; sys.exit(0)']) + except subprocess.CalledProcessError: + __cached_interp_requires_environment = True + else: + __cached_interp_requires_environment = False + + return __cached_interp_requires_environment + + +_PythonRunResult = collections.namedtuple("_PythonRunResult", + ("rc", "out", "err")) + + +# Executing the interpreter in a subprocess +def run_python_until_end(*args, **env_vars): + env_required = interpreter_requires_environment() + if '__isolated' in env_vars: + isolated = env_vars.pop('__isolated') + else: + isolated = not env_vars and not env_required + cmd_line = [sys.executable, '-X', 'faulthandler'] + if isolated: + # isolated mode: ignore Python environment variables, ignore user + # site-packages, and don't add the current directory to sys.path + cmd_line.append('-I') + elif not env_vars and not env_required: + # ignore Python environment variables + cmd_line.append('-E') + # Need to preserve the original environment, for in-place testing of + # shared library builds. + env = os.environ.copy() + # But a special flag that can be set to override -- in this case, the + # caller is responsible to pass the full environment. + if env_vars.pop('__cleanenv', None): + env = {} + env.update(env_vars) + cmd_line.extend(args) + p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + env=env) + try: + out, err = p.communicate() + finally: + subprocess._cleanup() + p.stdout.close() + p.stderr.close() + rc = p.returncode + err = strip_python_stderr(err) + return _PythonRunResult(rc, out, err), cmd_line + +def _assert_python(expected_success, *args, **env_vars): + res, cmd_line = run_python_until_end(*args, **env_vars) + if (res.rc and expected_success) or (not res.rc and not expected_success): + # Limit to 80 lines to ASCII characters + maxlen = 80 * 100 + out, err = res.out, res.err + if len(out) > maxlen: + out = b'(... truncated stdout ...)' + out[-maxlen:] + if len(err) > maxlen: + err = b'(... truncated stderr ...)' + err[-maxlen:] + out = out.decode('ascii', 'replace').rstrip() + err = err.decode('ascii', 'replace').rstrip() + raise AssertionError("Process return code is %d\n" + "command line: %r\n" + "\n" + "stdout:\n" + "---\n" + "%s\n" + "---\n" + "\n" + "stderr:\n" + "---\n" + "%s\n" + "---" + % (res.rc, cmd_line, + out, + err)) + return res + +def assert_python_ok(*args, **env_vars): + """ + Assert that running the interpreter with `args` and optional environment + variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, + stderr) tuple. + + If the __cleanenv keyword is set, env_vars is used a fresh environment. + + Python is started in isolated mode (command line option -I), + except if the __isolated keyword is set to False. + """ + return _assert_python(True, *args, **env_vars) + +def assert_python_failure(*args, **env_vars): + """ + Assert that running the interpreter with `args` and optional environment + variables `env_vars` fails (rc != 0) and return a (return code, stdout, + stderr) tuple. + + See assert_python_ok() for more options. + """ + return _assert_python(False, *args, **env_vars) + +def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw): + """Run a Python subprocess with the given arguments. + + kw is extra keyword args to pass to subprocess.Popen. Returns a Popen + object. + """ + cmd_line = [sys.executable, '-E'] + cmd_line.extend(args) + # Under Fedora (?), GNU readline can output junk on stderr when initialized, + # depending on the TERM setting. Setting TERM=vt100 is supposed to disable + # that. References: + # - http://reinout.vanrees.org/weblog/2009/08/14/readline-invisible-character-hack.html + # - http://stackoverflow.com/questions/15760712/python-readline-module-prints-escape-character-during-import + # - http://lists.gnu.org/archive/html/bug-readline/2007-08/msg00004.html + env = kw.setdefault('env', dict(os.environ)) + env['TERM'] = 'vt100' + return subprocess.Popen(cmd_line, stdin=subprocess.PIPE, + stdout=stdout, stderr=stderr, + **kw) + +def kill_python(p): + """Run the given Popen process until completion and return stdout.""" + p.stdin.close() + data = p.stdout.read() + p.stdout.close() + # try to cleanup the child so we don't appear to leak when running + # with regrtest -R. + p.wait() + subprocess._cleanup() + return data + +def make_script(script_dir, script_basename, source, omit_suffix=False): + script_filename = script_basename + if not omit_suffix: + script_filename += os.extsep + 'py' + script_name = os.path.join(script_dir, script_filename) + # The script should be encoded to UTF-8, the default string encoding + script_file = open(script_name, 'w', encoding='utf-8') + script_file.write(source) + script_file.close() + importlib.invalidate_caches() + return script_name + +def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None): + zip_filename = zip_basename+os.extsep+'zip' + zip_name = os.path.join(zip_dir, zip_filename) + zip_file = zipfile.ZipFile(zip_name, 'w') + if name_in_zip is None: + parts = script_name.split(os.sep) + if len(parts) >= 2 and parts[-2] == '__pycache__': + legacy_pyc = make_legacy_pyc(source_from_cache(script_name)) + name_in_zip = os.path.basename(legacy_pyc) + script_name = legacy_pyc + else: + name_in_zip = os.path.basename(script_name) + zip_file.write(script_name, name_in_zip) + zip_file.close() + #if test.support.verbose: + # zip_file = zipfile.ZipFile(zip_name, 'r') + # print 'Contents of %r:' % zip_name + # zip_file.printdir() + # zip_file.close() + return zip_name, os.path.join(zip_name, name_in_zip) + +def make_pkg(pkg_dir, init_source=''): + os.mkdir(pkg_dir) + make_script(pkg_dir, '__init__', init_source) + +def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, + source, depth=1, compiled=False): + unlink = [] + init_name = make_script(zip_dir, '__init__', '') + unlink.append(init_name) + init_basename = os.path.basename(init_name) + script_name = make_script(zip_dir, script_basename, source) + unlink.append(script_name) + if compiled: + init_name = py_compile.compile(init_name, doraise=True) + script_name = py_compile.compile(script_name, doraise=True) + unlink.extend((init_name, script_name)) + pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)] + script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name)) + zip_filename = zip_basename+os.extsep+'zip' + zip_name = os.path.join(zip_dir, zip_filename) + zip_file = zipfile.ZipFile(zip_name, 'w') + for name in pkg_names: + init_name_in_zip = os.path.join(name, init_basename) + zip_file.write(init_name, init_name_in_zip) + zip_file.write(script_name, script_name_in_zip) + zip_file.close() + for name in unlink: + os.unlink(name) + #if test.support.verbose: + # zip_file = zipfile.ZipFile(zip_name, 'r') + # print 'Contents of %r:' % zip_name + # zip_file.printdir() + # zip_file.close() + return zip_name, os.path.join(zip_name, script_name_in_zip) diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_asyncio/test_base_events.py --- a/Lib/test/test_asyncio/test_base_events.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_asyncio/test_base_events.py Thu Apr 16 17:08:37 2015 -0700 @@ -16,7 +16,7 @@ from asyncio import test_utils try: from test import support - from test.script_helper import assert_python_ok + from test.support.script_helper import assert_python_ok except ImportError: from asyncio import test_support as support from asyncio.test_support import assert_python_ok diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_asyncio/test_tasks.py Thu Apr 16 17:08:37 2015 -0700 @@ -13,7 +13,7 @@ from asyncio import test_utils try: from test import support - from test.script_helper import assert_python_ok + from test.support.script_helper import assert_python_ok except ImportError: from asyncio import test_support as support from asyncio.test_support import assert_python_ok diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_builtin.py Thu Apr 16 17:08:37 2015 -0700 @@ -16,7 +16,7 @@ import warnings from operator import neg from test.support import TESTFN, unlink, run_unittest, check_warnings -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok try: import pty, signal except ImportError: diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_calendar.py Thu Apr 16 17:08:37 2015 -0700 @@ -2,7 +2,7 @@ import unittest from test import support -from test.script_helper import assert_python_ok, assert_python_failure +from test.support.script_helper import assert_python_ok, assert_python_failure import time import locale import sys diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_capi.py --- a/Lib/test/test_capi.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_capi.py Thu Apr 16 17:08:37 2015 -0700 @@ -11,7 +11,7 @@ import unittest from test import support from test.support import MISSING_C_DOCSTRINGS -from test.script_helper import assert_python_failure +from test.support.script_helper import assert_python_failure try: import _posixsubprocess except ImportError: diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_cgitb.py --- a/Lib/test/test_cgitb.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_cgitb.py Thu Apr 16 17:08:37 2015 -0700 @@ -1,4 +1,5 @@ -from test.script_helper import assert_python_failure, temp_dir +from test.support import temp_dir +from test.support.script_helper import assert_python_failure import unittest import sys import cgitb diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_cmd_line.py Thu Apr 16 17:08:37 2015 -0700 @@ -8,8 +8,8 @@ import sys import subprocess import tempfile -from test import script_helper -from test.script_helper import (spawn_python, kill_python, assert_python_ok, +from test.support import script_helper +from test.support.script_helper import (spawn_python, kill_python, assert_python_ok, assert_python_failure) @@ -59,7 +59,7 @@ def test_xoptions(self): def get_xoptions(*args): - # use subprocess module directly because test.script_helper adds + # use subprocess module directly because test.support.script_helper adds # "-X faulthandler" to the command line args = (sys.executable, '-E') + args args += ('-c', 'import sys; print(sys._xoptions)') diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_cmd_line_script.py Thu Apr 16 17:08:37 2015 -0700 @@ -13,10 +13,9 @@ import textwrap from test import support -from test.script_helper import ( +from test.support.script_helper import ( make_pkg, make_script, make_zip_pkg, make_zip_script, - assert_python_ok, assert_python_failure, temp_dir, - spawn_python, kill_python) + assert_python_ok, assert_python_failure, spawn_python, kill_python) verbose = support.verbose @@ -223,14 +222,14 @@ self.check_repl_stderr_flush(True) def test_basic_script(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script') self._check_script(script_name, script_name, script_name, script_dir, None, importlib.machinery.SourceFileLoader) def test_script_compiled(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script') py_compile.compile(script_name, doraise=True) os.remove(script_name) @@ -240,14 +239,14 @@ importlib.machinery.SourcelessFileLoader) def test_directory(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__') self._check_script(script_dir, script_name, script_dir, script_dir, '', importlib.machinery.SourceFileLoader) def test_directory_compiled(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__') py_compile.compile(script_name, doraise=True) os.remove(script_name) @@ -257,19 +256,19 @@ importlib.machinery.SourcelessFileLoader) def test_directory_error(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: msg = "can't find '__main__' module in %r" % script_dir self._check_import_error(script_dir, msg) def test_zipfile(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__') zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name) self._check_script(zip_name, run_name, zip_name, zip_name, '', zipimport.zipimporter) def test_zipfile_compiled(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__') compiled_name = py_compile.compile(script_name, doraise=True) zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name) @@ -277,14 +276,14 @@ zipimport.zipimporter) def test_zipfile_error(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'not_main') zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name) msg = "can't find '__main__' module in %r" % zip_name self._check_import_error(zip_name, msg) def test_module_in_package(self): - with temp_dir() as script_dir: + with support.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, 'script') @@ -294,14 +293,14 @@ importlib.machinery.SourceFileLoader) def test_module_in_package_in_zipfile(self): - with temp_dir() as script_dir: + with support.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, run_name, run_name, zip_name, 'test_pkg', zipimport.zipimporter) def test_module_in_subpackage_in_zipfile(self): - with temp_dir() as script_dir: + with support.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, run_name, run_name, @@ -309,7 +308,7 @@ zipimport.zipimporter) def test_package(self): - with temp_dir() as script_dir: + with support.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__') @@ -319,7 +318,7 @@ importlib.machinery.SourceFileLoader) def test_package_compiled(self): - with temp_dir() as script_dir: + with support.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__') @@ -332,7 +331,7 @@ importlib.machinery.SourcelessFileLoader) def test_package_error(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir) msg = ("'test_pkg' is a package and cannot " @@ -341,7 +340,7 @@ self._check_import_error(launch_name, msg) def test_package_recursion(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir) main_dir = os.path.join(pkg_dir, '__main__') @@ -355,7 +354,7 @@ def test_issue8202(self): # Make sure package __init__ modules see "-m" in sys.argv0 while # searching for the module to execute - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: with support.change_cwd(path=script_dir): pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir, "import sys; print('init_argv0==%r' % sys.argv[0])") @@ -372,7 +371,7 @@ def test_issue8202_dash_c_file_ignored(self): # Make sure a "-c" file in the current directory # does not alter the value of sys.path[0] - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: with support.change_cwd(path=script_dir): with open("-c", "w") as f: f.write("data") @@ -387,7 +386,7 @@ def test_issue8202_dash_m_file_ignored(self): # Make sure a "-m" file in the current directory # does not alter the value of sys.path[0] - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'other') with support.change_cwd(path=script_dir): with open("-m", "w") as f: @@ -402,7 +401,7 @@ # If a module is invoked with the -m command line flag # and results in an error that the return code to the # shell is '1' - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: with support.change_cwd(path=script_dir): pkg_dir = os.path.join(script_dir, 'test_pkg') make_pkg(pkg_dir) @@ -422,7 +421,7 @@ except: raise NameError from None """) - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script', script) exitcode, stdout, stderr = assert_python_failure(script_name) text = stderr.decode('ascii').split('\n') @@ -466,7 +465,7 @@ if error: sys.exit(error) """) - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script', script) exitcode, stdout, stderr = assert_python_failure(script_name) text = stderr.decode('ascii') diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_compileall.py Thu Apr 16 17:08:37 2015 -0700 @@ -17,7 +17,8 @@ except ImportError: _have_multiprocessing = False -from test import support, script_helper +from test import support +from test.support import script_helper class CompileallTests(unittest.TestCase): diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_concurrent_futures.py --- a/Lib/test/test_concurrent_futures.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_concurrent_futures.py Thu Apr 16 17:08:37 2015 -0700 @@ -9,7 +9,7 @@ # without thread support. test.support.import_module('threading') -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok import os import sys diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_crashers.py --- a/Lib/test/test_crashers.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_crashers.py Thu Apr 16 17:08:37 2015 -0700 @@ -8,7 +8,7 @@ import glob import os.path import test.support -from test.script_helper import assert_python_failure +from test.support.script_helper import assert_python_failure CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers") CRASHER_FILES = os.path.join(CRASHER_DIR, "*.py") diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_doctest.py Thu Apr 16 17:08:37 2015 -0700 @@ -2729,8 +2729,8 @@ simple tests and no errors. We'll run both the unadorned doctest command, and the verbose version, and then check the output: - >>> from test import script_helper - >>> with script_helper.temp_dir() as tmpdir: + >>> from test.support import script_helper, temp_dir + >>> with temp_dir() as tmpdir: ... fn = os.path.join(tmpdir, 'myfile.doc') ... with open(fn, 'w') as f: ... _ = f.write('This is a very simple test file.\n') @@ -2780,8 +2780,8 @@ file ends in '.py', its handling of python module files (as opposed to straight text files). - >>> from test import script_helper - >>> with script_helper.temp_dir() as tmpdir: + >>> from test.support import script_helper, temp_dir + >>> with temp_dir() as tmpdir: ... fn = os.path.join(tmpdir, 'myfile.doc') ... with open(fn, 'w') as f: ... _ = f.write('This is another simple test file.\n') diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_eintr.py --- a/Lib/test/test_eintr.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_eintr.py Thu Apr 16 17:08:37 2015 -0700 @@ -2,7 +2,9 @@ import signal import unittest -from test import script_helper, support +from test import support +from test.support import script_helper + @unittest.skipUnless(os.name == "posix", "only supported on Unix") diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_faulthandler.py --- a/Lib/test/test_faulthandler.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_faulthandler.py Thu Apr 16 17:08:37 2015 -0700 @@ -6,8 +6,9 @@ import signal import subprocess import sys -from test import support, script_helper -from test.script_helper import assert_python_ok +from test import support +from test.support import script_helper +from test.support.script_helper import assert_python_ok import tempfile import unittest from textwrap import dedent diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_gc.py --- a/Lib/test/test_gc.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_gc.py Thu Apr 16 17:08:37 2015 -0700 @@ -1,7 +1,8 @@ import unittest from test.support import (verbose, refcount_test, run_unittest, - strip_python_stderr, cpython_only, start_threads) -from test.script_helper import assert_python_ok, make_script, temp_dir + strip_python_stderr, cpython_only, start_threads, + temp_dir) +from test.support.script_helper import assert_python_ok, make_script import sys import time diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_hash.py --- a/Lib/test/test_hash.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_hash.py Thu Apr 16 17:08:37 2015 -0700 @@ -7,7 +7,7 @@ import os import sys import unittest -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok from collections import Hashable IS_64BIT = sys.maxsize > 2**32 diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_import/__init__.py --- a/Lib/test/test_import/__init__.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_import/__init__.py Thu Apr 16 17:08:37 2015 -0700 @@ -21,8 +21,9 @@ from test.support import ( EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython, make_legacy_pyc, rmtree, run_unittest, swap_attr, swap_item, temp_umask, - unlink, unload, create_empty_file, cpython_only, TESTFN_UNENCODABLE) -from test import script_helper + unlink, unload, create_empty_file, cpython_only, TESTFN_UNENCODABLE, + temp_dir) +from test.support import script_helper skip_if_dont_write_bytecode = unittest.skipIf( @@ -45,7 +46,7 @@ # temporarily clears the module from sys.modules (if any) # reverts or removes the module when cleaning up name = name or "spam" - with script_helper.temp_dir() as tempdir: + with temp_dir() as tempdir: path = script_helper.make_script(tempdir, name, source) old_module = sys.modules.pop(name, None) try: diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_inspect.py Thu Apr 16 17:08:37 2015 -0700 @@ -26,7 +26,7 @@ from test.support import run_unittest, TESTFN, DirsOnSysPath, cpython_only from test.support import MISSING_C_DOCSTRINGS, cpython_only -from test.script_helper import assert_python_ok, assert_python_failure +from test.support.script_helper import assert_python_ok, assert_python_failure from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_io.py --- a/Lib/test/test_io.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_io.py Thu Apr 16 17:08:37 2015 -0700 @@ -35,7 +35,7 @@ from collections import deque, UserList from itertools import cycle, count from test import support -from test.script_helper import assert_python_ok, run_python_until_end +from test.support.script_helper import assert_python_ok, run_python_until_end import codecs import io # C implementation of io diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_json/test_tool.py --- a/Lib/test/test_json/test_tool.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_json/test_tool.py Thu Apr 16 17:08:37 2015 -0700 @@ -4,7 +4,7 @@ import unittest import subprocess from test import support -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok class TestTool(unittest.TestCase): diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_logging.py --- a/Lib/test/test_logging.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_logging.py Thu Apr 16 17:08:37 2015 -0700 @@ -38,7 +38,7 @@ import struct import sys import tempfile -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok from test import support import textwrap import time diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_module.py --- a/Lib/test/test_module.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_module.py Thu Apr 16 17:08:37 2015 -0700 @@ -2,7 +2,7 @@ import unittest import weakref from test.support import gc_collect -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok import sys ModuleType = type(sys) diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_multiprocessing_main_handling.py --- a/Lib/test/test_multiprocessing_main_handling.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_multiprocessing_main_handling.py Thu Apr 16 17:08:37 2015 -0700 @@ -13,10 +13,9 @@ import os.path import py_compile -from test.script_helper import ( +from test.support.script_helper import ( make_pkg, make_script, make_zip_pkg, make_zip_script, - assert_python_ok, assert_python_failure, temp_dir, - spawn_python, kill_python) + assert_python_ok, assert_python_failure, spawn_python, kill_python) # Look up which start methods are available to test import multiprocessing @@ -157,12 +156,12 @@ self._check_output(script_name, rc, out, err) def test_basic_script(self): - with temp_dir() as script_dir: + with support.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 temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script', omit_suffix=True) self._check_script(script_name) @@ -173,7 +172,7 @@ # a workaround for that case # See https://github.com/ipython/ipython/issues/4698 source = test_source_main_skipped_in_children - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'ipython', source=source) self._check_script(script_name) @@ -183,7 +182,7 @@ self._check_script(script_no_suffix) def test_script_compiled(self): - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, 'script') py_compile.compile(script_name, doraise=True) os.remove(script_name) @@ -192,14 +191,14 @@ def test_directory(self): source = self.main_in_children_source - with temp_dir() as script_dir: + with support.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 temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__', source=source) py_compile.compile(script_name, doraise=True) @@ -209,7 +208,7 @@ def test_zipfile(self): source = self.main_in_children_source - with temp_dir() as script_dir: + with support.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) @@ -217,7 +216,7 @@ def test_zipfile_compiled(self): source = self.main_in_children_source - with temp_dir() as script_dir: + with support.temp_dir() as script_dir: script_name = _make_test_script(script_dir, '__main__', source=source) compiled_name = py_compile.compile(script_name, doraise=True) @@ -225,7 +224,7 @@ self._check_script(zip_name) def test_module_in_package(self): - with temp_dir() as script_dir: + with support.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') @@ -234,20 +233,20 @@ self._check_script(launch_name) def test_module_in_package_in_zipfile(self): - with temp_dir() as script_dir: + with support.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 temp_dir() as script_dir: + with support.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 temp_dir() as script_dir: + with support.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__', @@ -257,7 +256,7 @@ def test_package_compiled(self): source = self.main_in_children_source - with temp_dir() as script_dir: + with support.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__', diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_os.py --- a/Lib/test/test_os.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_os.py Thu Apr 16 17:08:37 2015 -0700 @@ -64,7 +64,7 @@ except ImportError: INT_MAX = PY_SSIZE_T_MAX = sys.maxsize -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok root_in_posix = False if hasattr(os, 'geteuid'): diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_parser.py --- a/Lib/test/test_parser.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_parser.py Thu Apr 16 17:08:37 2015 -0700 @@ -4,7 +4,7 @@ import operator import struct from test import support -from test.script_helper import assert_python_failure +from test.support.script_helper import assert_python_failure # # First, we test that we can generate trees from valid source fragments, diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_pydoc.py Thu Apr 16 17:08:37 2015 -0700 @@ -21,7 +21,7 @@ import textwrap from io import StringIO from collections import namedtuple -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok from test.support import ( TESTFN, rmtree, reap_children, reap_threads, captured_output, captured_stdout, diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_readline.py --- a/Lib/test/test_readline.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_readline.py Thu Apr 16 17:08:37 2015 -0700 @@ -5,7 +5,7 @@ import tempfile import unittest from test.support import import_module, unlink -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok # Skip tests if there is no readline module readline = import_module('readline') diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_runpy.py Thu Apr 16 17:08:37 2015 -0700 @@ -9,9 +9,9 @@ import py_compile from test.support import ( forget, make_legacy_pyc, unload, verbose, no_tracing, - create_empty_file) -from test.script_helper import ( - make_pkg, make_script, make_zip_pkg, make_zip_script, temp_dir) + create_empty_file, temp_dir) +from test.support.script_helper import ( + make_pkg, make_script, make_zip_pkg, make_zip_script) import runpy diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_script_helper.py --- a/Lib/test/test_script_helper.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_script_helper.py Thu Apr 16 17:08:37 2015 -0700 @@ -1,8 +1,8 @@ -"""Unittests for test.script_helper. Who tests the test helper?""" +"""Unittests for test.support.script_helper. Who tests the test helper?""" import subprocess import sys -from test import script_helper +from test.support import script_helper import unittest from unittest import mock diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_signal.py --- a/Lib/test/test_signal.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_signal.py Thu Apr 16 17:08:37 2015 -0700 @@ -11,7 +11,7 @@ import subprocess import traceback import sys, os, time, errno -from test.script_helper import assert_python_ok, spawn_python +from test.support.script_helper import assert_python_ok, spawn_python try: import threading except ImportError: diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_subprocess.py Thu Apr 16 17:08:37 2015 -0700 @@ -1,5 +1,5 @@ import unittest -from test import script_helper +from test.support import script_helper from test import support import subprocess import sys @@ -394,7 +394,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 script_helper.temp_dir() as wrong_dir: + with support.temp_dir() as wrong_dir: # Before calling with an absolute path, confirm that using a # relative path fails. self.assertRaises(FileNotFoundError, subprocess.Popen, diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_sys.py --- a/Lib/test/test_sys.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_sys.py Thu Apr 16 17:08:37 2015 -0700 @@ -1,5 +1,5 @@ import unittest, test.support -from test.script_helper import assert_python_ok, assert_python_failure +from test.support.script_helper import assert_python_ok, assert_python_failure import sys, io, os import struct import subprocess @@ -708,7 +708,7 @@ @test.support.cpython_only def test_debugmallocstats(self): # Test sys._debugmallocstats() - from test.script_helper import assert_python_ok + from test.support.script_helper import assert_python_ok args = ['-c', 'import sys; sys._debugmallocstats()'] ret, out, err = assert_python_ok(*args) self.assertIn(b"free PyDictObjects", err) diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_tarfile.py Thu Apr 16 17:08:37 2015 -0700 @@ -6,7 +6,8 @@ import unittest import tarfile -from test import support, script_helper +from test import support +from test.support import script_helper # Check for our compression modules. try: diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_tempfile.py Thu Apr 16 17:08:37 2015 -0700 @@ -12,7 +12,8 @@ from unittest import mock import unittest -from test import support, script_helper +from test import support +from test.support import script_helper if hasattr(os, 'stat'): diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_threading.py --- a/Lib/test/test_threading.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_threading.py Thu Apr 16 17:08:37 2015 -0700 @@ -4,7 +4,7 @@ import test.support from test.support import verbose, strip_python_stderr, import_module, cpython_only -from test.script_helper import assert_python_ok, assert_python_failure +from test.support.script_helper import assert_python_ok, assert_python_failure import random import re diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_tools/test_md5sum.py --- a/Lib/test/test_tools/test_md5sum.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_tools/test_md5sum.py Thu Apr 16 17:08:37 2015 -0700 @@ -4,7 +4,7 @@ import sys import unittest from test import support -from test.script_helper import assert_python_ok, assert_python_failure +from test.support.script_helper import assert_python_ok, assert_python_failure from test.test_tools import scriptsdir, import_tool, skip_if_missing diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_tools/test_pindent.py --- a/Lib/test/test_tools/test_pindent.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_tools/test_pindent.py Thu Apr 16 17:08:37 2015 -0700 @@ -6,7 +6,7 @@ import subprocess import textwrap from test import support -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok from test.test_tools import scriptsdir, skip_if_missing diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_tools/test_reindent.py --- a/Lib/test/test_tools/test_reindent.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_tools/test_reindent.py Thu Apr 16 17:08:37 2015 -0700 @@ -6,7 +6,7 @@ import os import unittest -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok from test.test_tools import scriptsdir, skip_if_missing diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_traceback.py --- a/Lib/test/test_traceback.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_traceback.py Thu Apr 16 17:08:37 2015 -0700 @@ -7,7 +7,7 @@ import unittest import re from test.support import TESTFN, Error, captured_output, unlink, cpython_only -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok import textwrap import traceback diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_tracemalloc.py --- a/Lib/test/test_tracemalloc.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_tracemalloc.py Thu Apr 16 17:08:37 2015 -0700 @@ -4,8 +4,9 @@ import tracemalloc import unittest from unittest.mock import patch -from test.script_helper import assert_python_ok, assert_python_failure -from test import script_helper, support +from test.support.script_helper import assert_python_ok, assert_python_failure +from test import support +from test.support import script_helper try: import threading except ImportError: diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_warnings.py Thu Apr 16 17:08:37 2015 -0700 @@ -5,7 +5,7 @@ import sys import unittest from test import support -from test.script_helper import assert_python_ok, assert_python_failure +from test.support.script_helper import assert_python_ok, assert_python_failure from test import warning_tests diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_weakref.py --- a/Lib/test/test_weakref.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_weakref.py Thu Apr 16 17:08:37 2015 -0700 @@ -7,7 +7,8 @@ import contextlib import copy -from test import support, script_helper +from test import support +from test.support import script_helper # Used in ReferencesTestCase.test_ref_created_during_del() . ref_from_del = None diff -r f0a00ee094ff -r 8711b188514a Lib/test/test_zipimport_support.py --- a/Lib/test/test_zipimport_support.py Tue Apr 14 16:14:25 2015 -0700 +++ b/Lib/test/test_zipimport_support.py Thu Apr 16 17:08:37 2015 -0700 @@ -14,8 +14,8 @@ import linecache import pdb import unittest -from test.script_helper import (spawn_python, kill_python, assert_python_ok, - temp_dir, make_script, make_zip_script) +from test.support.script_helper import (spawn_python, kill_python, assert_python_ok, + make_script, make_zip_script) verbose = test.support.verbose @@ -78,7 +78,7 @@ def test_inspect_getsource_issue4223(self): test_src = "def foo(): pass\n" - with temp_dir() as d: + with test.support.temp_dir() as d: init_name = make_script(d, '__init__', test_src) name_in_zip = os.path.join('zip_pkg', os.path.basename(init_name)) @@ -118,7 +118,7 @@ mod_name = mod_name.replace("sample_", "sample_zipped_") sample_sources[mod_name] = src - with temp_dir() as d: + with test.support.temp_dir() as d: script_name = make_script(d, 'test_zipped_doctest', test_src) zip_name, run_name = make_zip_script(d, 'test_zip', @@ -195,7 +195,7 @@ doctest.testmod() """) pattern = 'File "%s", line 2, in %s' - with temp_dir() as d: + with test.support.temp_dir() as d: script_name = make_script(d, 'script', test_src) rc, out, err = assert_python_ok(script_name) expected = pattern % (script_name, "__main__.Test") @@ -222,7 +222,7 @@ import pdb pdb.Pdb(nosigint=True).runcall(f) """) - with temp_dir() as d: + with test.support.temp_dir() as d: script_name = make_script(d, 'script', test_src) p = spawn_python(script_name) p.stdin.write(b'l\n')