diff -r 2e856fcb9084 Doc/library/test.rst --- a/Doc/library/test.rst Tue Dec 17 21:14:41 2013 -0500 +++ b/Doc/library/test.rst Wed Dec 18 22:24:30 2013 +1000 @@ -605,3 +605,147 @@ Class used to record warnings for unit tests. See documentation of :func:`check_warnings` above for more details. + + +Helper utilities for script creation and execution +-------------------------------------------------- + +.. module:: test.support.script_helper + :synopsis: Script creation and execution + +The :mod:`test.support.script_helper` module defines common utilities used +across various tests, such as creating scripts in temporary directories or +running python subprocesses based on given arguments. + +This module defines the following functions: + +.. function:: assert_python_ok(*args, **env_vars) + + Checks that running the interpreter with *args* and optional environment + variables *env_vars* succeeds (``rc == 0``) + + Returns a (return code, stdout, stderr) tuple on success, throws an + appropriate :exc:`AssertionError`` for a non-zero return code. + + If the *__cleanenv* keyword is set, *env_vars* is used as a fresh + environment, otherwise it is added to the environment of the current + process. + + Python is started in isolated mode (command line option ``-I``), + except if the *__isolated* keyword is present and set to False. + +.. function:: assert_python_failure(*args, **env_vars) + + Checks that running the interpreter with *args* and optional environment + variables *env_vars* fails (``rc != 0``). + + Returns a (return code, stdout, stderr) tuple on failure, throws an + appropriate :exc:`AssertionError`` if the return code is zero. + + If the *__cleanenv* keyword is set, *env_vars* is used as a fresh + environment, otherwise it is added to the environment of the current + process. + + Python is started in isolated mode (command line option ``-I``), + except if the *__isolated* keyword is present and set to False. + +.. function:: spawn_python(*args, **kw) + + Runs a Python subprocess with the given arguments and returns the + resulting :class:`subprocess.Popen` instance. + + The ``-E`` option is always passed to the subprocess, both ``stdin`` and + ``stdout`` are configured as binary pipes and ``stderr`` is merged with + ``stdout``.. + + *kw* is passed through to subprocess.Popen as additional keyword + arguments. + +.. function:: kill_python(p) + + Runs the given Popen process until completion and return stdout. + + This will also include stderr output if the process was started with + :func:`spawn_python`. + +.. function:: make_script(script_dir, script_basename, \ + source, omit_suffix=False) + + Creates a new Python script/module in the given directory. + + This function invalidates the import system caches, allowing the created + file to be immediately imported. + + By default, *script_dir* and *script_basename* are combined with + :data:`os.extsep` and the normal ``py`` extension to create the full + path to the file. If *omit_suffix* is true, the base name is used + directly as the name of created file with no extension. + + *source* is a Unicode string which will be written to the file as UTF-8. + +.. function:: make_zip_script(zip_dir, zip_basename, \ + script_name, name_in_zip=None) + + Creates a new zip archive in the given directory, containing the specified + Python script/module + + This function invalidates the import system caches, allowing the created + file to be immediately imported. + + By default, the script is placed at the base of the zip archive using + just the same filename as the script itself. This can be changed by + specifying the *name_in_zip* parameter to choose a particular name. + + There is also a special case for when *script_name* refers to a file + in a ``__pycache__`` directory. In that case, the helper will create a + new compiled bytecode file from the original source file using the + legacy naming scheme and place that in the zip archive instead. + +.. function:: make_pkg(pkg_dir, init_source='') + + Creates a simple self-contained Python package, optionally with a + non-empty init file. + + This function invalidates the import system caches, allowing the created + directory to be immediately imported. + + Equivalent to:: + + os.mkdir(pkg_dir) + make_script(pkg_dir, "__init__", init_source) + + +.. function:: make_zip_pkg(zip_dir, zip_basename, \ + pkg_name, script_basename, source, \ + depth=1, compiled=False) + + Create a self-contained Python package inside a new zip archive in the + given directory. + + This function invalidates the import system caches, allowing the contents + of the created archive to be immediately imported. + + For example, this call:: + + make_zip_pkg('.', 'example', 'mypkg', 'submodule', '', depth=2) + + Would create an archive in the current directory called ``example.zip`` + with the layout:: + + mypkg/ + __init__.py + mypkg/ + __init__.py + submodule.py + + The init modules in the packages inside the archive are always empty, + while *source* is written to the submodule named by *script_basename*. + + *depth* controls how many deeply nested the package is. + + If *compiled* is true, then the the files added to the archive will be + suitable named compiled bytecode files rather than the original source + files. + + + diff -r 2e856fcb9084 Lib/test/_test_multiprocessing.py --- a/Lib/test/_test_multiprocessing.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/_test_multiprocessing.py Wed Dec 18 22:24:30 2013 +1000 @@ -21,7 +21,7 @@ import struct import operator import test.support -import test.script_helper +from test.support import script_helper # Skip tests if _multiprocessing wasn't built. @@ -3396,11 +3396,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 = script_helper.assert_python_failure(name, sm) self.assertEqual('', out.decode('ascii')) self.assertIn('RuntimeError', err.decode('ascii')) else: - rc, out, err = test.script_helper.assert_python_ok(name, sm) + rc, out, err = script_helper.assert_python_ok(name, sm) self.assertEqual('123', out.decode('ascii').rstrip()) self.assertEqual('', err.decode('ascii')) diff -r 2e856fcb9084 Lib/test/script_helper.py --- a/Lib/test/script_helper.py Tue Dec 17 21:14:41 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -# Common utility functions used by various script execution tests -# e.g. test_cmd_line, test_cmd_line_script and test_runpy - -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 - -# Executing the interpreter in a subprocess -def _assert_python(expected_success, *args, **env_vars): - if '__isolated' in env_vars: - isolated = env_vars.pop('__isolated') - else: - isolated = not env_vars - 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: - # 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) - if (rc and expected_success) or (not rc and not expected_success): - raise AssertionError( - "Process return code is %d, " - "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore'))) - return rc, out, err - -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, **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) - return subprocess.Popen(cmd_line, stdin=subprocess.PIPE, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - **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(init_name, doraise=True) - script_name = py_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 2e856fcb9084 Lib/test/support/script_helper.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/support/script_helper.py Wed Dec 18 22:24:30 2013 +1000 @@ -0,0 +1,170 @@ +# Common utility functions used by various script execution tests +# e.g. test_cmd_line, test_cmd_line_script and test_runpy + +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 + +# Executing the interpreter in a subprocess +def _assert_python(expected_success, *args, **env_vars): + if '__isolated' in env_vars: + isolated = env_vars.pop('__isolated') + else: + isolated = not env_vars + 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: + # 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) + if (rc and expected_success) or (not rc and not expected_success): + raise AssertionError( + "Process return code is %d, " + "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore'))) + return rc, out, err + +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, **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) + return subprocess.Popen(cmd_line, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + **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(init_name, doraise=True) + script_name = py_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 2e856fcb9084 Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_calendar.py Wed Dec 18 22:24:30 2013 +1000 @@ -2,7 +2,7 @@ import unittest from test import support -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok import time import locale import sys diff -r 2e856fcb9084 Lib/test/test_cgitb.py --- a/Lib/test/test_cgitb.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_cgitb.py Wed Dec 18 22:24:30 2013 +1000 @@ -1,5 +1,5 @@ from test.support import run_unittest -from test.script_helper import assert_python_failure, temp_dir +from test.support.script_helper import assert_python_failure, temp_dir import unittest import sys import cgitb diff -r 2e856fcb9084 Lib/test/test_cmd_line.py --- a/Lib/test/test_cmd_line.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_cmd_line.py Wed Dec 18 22:24:30 2013 +1000 @@ -8,8 +8,9 @@ import sys import subprocess import tempfile -from test.script_helper import (spawn_python, kill_python, assert_python_ok, - assert_python_failure) +from test.support.script_helper import (spawn_python, kill_python, + assert_python_ok, + assert_python_failure) # XXX (ncoghlan): Move to script_helper and make consistent with run_python @@ -58,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 script_helper adds # "-X faulthandler" to the command line args = (sys.executable, '-E') + args args += ('-c', 'import sys; print(sys._xoptions)') diff -r 2e856fcb9084 Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_cmd_line_script.py Wed Dec 18 22:24:30 2013 +1000 @@ -11,7 +11,7 @@ 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) diff -r 2e856fcb9084 Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_compileall.py Wed Dec 18 22:24:30 2013 +1000 @@ -10,7 +10,8 @@ import unittest import io -from test import support, script_helper +from test import support +from test.support import script_helper class CompileallTests(unittest.TestCase): diff -r 2e856fcb9084 Lib/test/test_concurrent_futures.py --- a/Lib/test/test_concurrent_futures.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_concurrent_futures.py Wed Dec 18 22:24:30 2013 +1000 @@ -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 sys import threading diff -r 2e856fcb9084 Lib/test/test_crashers.py --- a/Lib/test/test_crashers.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_crashers.py Wed Dec 18 22:24:30 2013 +1000 @@ -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 2e856fcb9084 Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_doctest.py Wed Dec 18 22:24:30 2013 +1000 @@ -2679,7 +2679,7 @@ 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 + >>> from test.support import script_helper >>> with script_helper.temp_dir() as tmpdir: ... fn = os.path.join(tmpdir, 'myfile.doc') ... with open(fn, 'w') as f: @@ -2730,7 +2730,7 @@ file ends in '.py', its handling of python module files (as opposed to straight text files). - >>> from test import script_helper + >>> from test.support import script_helper >>> with script_helper.temp_dir() as tmpdir: ... fn = os.path.join(tmpdir, 'myfile.doc') ... with open(fn, 'w') as f: diff -r 2e856fcb9084 Lib/test/test_faulthandler.py --- a/Lib/test/test_faulthandler.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_faulthandler.py Wed Dec 18 22:24:30 2013 +1000 @@ -6,8 +6,8 @@ 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.script_helper import spawn_python, assert_python_ok import tempfile import unittest @@ -48,7 +48,7 @@ thread XXX". """ with support.SuppressCrashReport(): - process = script_helper.spawn_python('-c', code) + process = spawn_python('-c', code) stdout, stderr = process.communicate() exitcode = process.wait() output = support.strip_python_stderr(stdout) diff -r 2e856fcb9084 Lib/test/test_gc.py --- a/Lib/test/test_gc.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_gc.py Wed Dec 18 22:24:30 2013 +1000 @@ -2,7 +2,8 @@ import unittest from test.support import (verbose, refcount_test, run_unittest, strip_python_stderr) -from test.script_helper import assert_python_ok, make_script, temp_dir +from test.support.script_helper import (assert_python_ok, make_script, + temp_dir) import sys import time diff -r 2e856fcb9084 Lib/test/test_hash.py --- a/Lib/test/test_hash.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_hash.py Wed Dec 18 22:24:30 2013 +1000 @@ -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 2e856fcb9084 Lib/test/test_import.py --- a/Lib/test/test_import.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_import.py Wed Dec 18 22:24:30 2013 +1000 @@ -22,7 +22,7 @@ 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 +from test.support import script_helper skip_if_dont_write_bytecode = unittest.skipIf( diff -r 2e856fcb9084 Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_inspect.py Wed Dec 18 22:24:30 2013 +1000 @@ -16,9 +16,10 @@ except ImportError: ThreadPoolExecutor = None -from test.support import run_unittest, TESTFN, DirsOnSysPath -from test.support import MISSING_C_DOCSTRINGS -from test.script_helper import assert_python_ok, assert_python_failure +from test.support import (run_unittest, TESTFN, DirsOnSysPath, + MISSING_C_DOCSTRINGS) +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 2e856fcb9084 Lib/test/test_json/test_tool.py --- a/Lib/test/test_json/test_tool.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_json/test_tool.py Wed Dec 18 22:24:30 2013 +1000 @@ -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): data = """ diff -r 2e856fcb9084 Lib/test/test_module.py --- a/Lib/test/test_module.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_module.py Wed Dec 18 22:24:30 2013 +1000 @@ -2,7 +2,7 @@ import unittest import weakref from test.support import run_unittest, 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 2e856fcb9084 Lib/test/test_multiprocessing_main_handling.py --- a/Lib/test/test_multiprocessing_main_handling.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_multiprocessing_main_handling.py Wed Dec 18 22:24:30 2013 +1000 @@ -10,7 +10,7 @@ import py_compile 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) diff -r 2e856fcb9084 Lib/test/test_os.py --- a/Lib/test/test_os.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_os.py Wed Dec 18 22:24:30 2013 +1000 @@ -40,7 +40,7 @@ except ImportError: fcntl = None -from test.script_helper import assert_python_ok +from test.support.script_helper import assert_python_ok with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) diff -r 2e856fcb9084 Lib/test/test_parser.py --- a/Lib/test/test_parser.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_parser.py Wed Dec 18 22:24:30 2013 +1000 @@ -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 2e856fcb9084 Lib/test/test_py_compile.py --- a/Lib/test/test_py_compile.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_py_compile.py Wed Dec 18 22:24:30 2013 +1000 @@ -7,7 +7,8 @@ import tempfile import unittest -from test import support, script_helper +from test import support +from test.support import script_helper class PyCompileTests(unittest.TestCase): diff -r 2e856fcb9084 Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_pydoc.py Wed Dec 18 22:24:30 2013 +1000 @@ -17,7 +17,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 2e856fcb9084 Lib/test/test_runpy.py --- a/Lib/test/test_runpy.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_runpy.py Wed Dec 18 22:24:30 2013 +1000 @@ -10,7 +10,7 @@ from test.support import ( forget, make_legacy_pyc, run_unittest, unload, verbose, no_tracing, create_empty_file) -from test.script_helper import ( +from test.support.script_helper import ( make_pkg, make_script, make_zip_pkg, make_zip_script, temp_dir) diff -r 2e856fcb9084 Lib/test/test_signal.py --- a/Lib/test/test_signal.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_signal.py Wed Dec 18 22:24:30 2013 +1000 @@ -9,7 +9,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 2e856fcb9084 Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_subprocess.py Wed Dec 18 22:24:30 2013 +1000 @@ -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 diff -r 2e856fcb9084 Lib/test/test_sys.py --- a/Lib/test/test_sys.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_sys.py Wed Dec 18 22:24:30 2013 +1000 @@ -660,7 +660,7 @@ 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 2e856fcb9084 Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_tarfile.py Wed Dec 18 22:24:30 2013 +1000 @@ -7,7 +7,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 2e856fcb9084 Lib/test/test_threading.py --- a/Lib/test/test_threading.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_threading.py Wed Dec 18 22:24:30 2013 +1000 @@ -4,7 +4,8 @@ import test.support from test.support import verbose, strip_python_stderr, import_module -from test.script_helper import assert_python_ok +from test.support.script_helper import (assert_python_ok, + assert_python_failure) import random import re @@ -16,7 +17,6 @@ import unittest import weakref import os -from test.script_helper import assert_python_ok, assert_python_failure import subprocess from test import lock_tests diff -r 2e856fcb9084 Lib/test/test_tools.py --- a/Lib/test/test_tools.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_tools.py Wed Dec 18 22:24:30 2013 +1000 @@ -15,7 +15,7 @@ import tempfile import textwrap from test import support -from test.script_helper import assert_python_ok, temp_dir +from test.support.script_helper import assert_python_ok, temp_dir if not sysconfig.is_python_build(): # XXX some installers do contain the tools, should we detect that diff -r 2e856fcb9084 Lib/test/test_tracemalloc.py --- a/Lib/test/test_tracemalloc.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_tracemalloc.py Wed Dec 18 22:24:30 2013 +1000 @@ -4,7 +4,8 @@ import tracemalloc import unittest from unittest.mock import patch -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 support try: import threading diff -r 2e856fcb9084 Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_warnings.py Wed Dec 18 22:24:30 2013 +1000 @@ -6,7 +6,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 from test import warning_tests diff -r 2e856fcb9084 Lib/test/test_weakref.py --- a/Lib/test/test_weakref.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_weakref.py Wed Dec 18 22:24:30 2013 +1000 @@ -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 2e856fcb9084 Lib/test/test_zipimport_support.py --- a/Lib/test/test_zipimport_support.py Tue Dec 17 21:14:41 2013 -0500 +++ b/Lib/test/test_zipimport_support.py Wed Dec 18 22:24:30 2013 +1000 @@ -14,8 +14,9 @@ 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, temp_dir, + make_script, make_zip_script) verbose = test.support.verbose