diff -r 5d43154d68a8 Lib/test/__main__.py --- a/Lib/test/__main__.py Sun Jul 08 21:03:01 2012 +0200 +++ b/Lib/test/__main__.py Sun Jul 08 19:52:15 2012 -0700 @@ -1,13 +1,3 @@ -from test import regrtest, support +from test import regrtest - -TEMPDIR, TESTCWD = regrtest._make_temp_dir_for_build(regrtest.TEMPDIR) -regrtest.TEMPDIR = TEMPDIR -regrtest.TESTCWD = TESTCWD - -# Run the tests in a context manager that temporary changes the CWD to a -# temporary and writable directory. If it's not possible to create or -# change the CWD, the original CWD will be used. The original CWD is -# available from support.SAVEDCWD. -with support.temp_cwd(TESTCWD, quiet=True): - regrtest.main() +regrtest.main_with_temp_cwd() diff -r 5d43154d68a8 Lib/test/regrtest.py --- a/Lib/test/regrtest.py Sun Jul 08 21:03:01 2012 +0200 +++ b/Lib/test/regrtest.py Sun Jul 08 19:52:15 2012 -0700 @@ -250,6 +250,20 @@ print("Use --help for usage", file=sys.stderr) sys.exit(2) +def main_with_temp_cwd(): + """Execute a test suite in a temporary working directory. + + """ + global TEMPDIR, TESTCWD + + TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR) + + # Run the tests in a context manager that temporarily changes the CWD to + # a temporary and writable directory. If it's not possible to create or + # change the CWD, the original CWD will be used. The original CWD is + # available from support.SAVEDCWD. + with support.temp_cwd(TESTCWD, quiet=True): + main() def main(tests=None, testdir=None, verbose=0, quiet=False, exclude=False, single=False, randomize=False, fromfile=None, @@ -1777,11 +1791,4 @@ # sanity check assert __file__ == os.path.abspath(sys.argv[0]) - TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR) - - # Run the tests in a context manager that temporary changes the CWD to a - # temporary and writable directory. If it's not possible to create or - # change the CWD, the original CWD will be used. The original CWD is - # available from support.SAVEDCWD. - with support.temp_cwd(TESTCWD, quiet=True): - main() + main_with_temp_cwd()