[Python-Dev] [Python-checkins] r86965 - python/branches/py3k/Lib/test/__main__.py

Nick Coghlan ncoghlan at gmail.com
Fri Dec 3 11:53:04 CET 2010


On Fri, Dec 3, 2010 at 8:42 PM, michael.foord
<python-checkins at python.org> wrote:
> +# When tests are run from the Python build directory, it is best practice
> +# to keep the test files in a subfolder.  It eases the cleanup of leftover
> +# files using command "make distclean".
> +if sysconfig.is_python_build():
> +    TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
> +    TEMPDIR = os.path.abspath(TEMPDIR)
> +    if not os.path.exists(TEMPDIR):
> +        os.mkdir(TEMPDIR)
> +    regrtest.TEMPDIR = TEMPDIR

If syconfig.is_python_build() returns False...

> +# Define a writable temp dir that will be used as cwd while running
> +# the tests. The name of the dir includes the pid to allow parallel
> +# testing (see the -j option).
> +TESTCWD = 'test_python_{}'.format(os.getpid())
> +
> +TESTCWD = os.path.join(TEMPDIR, TESTCWD)

... this line is going to blow up with a NameError.

I would suggest putting this common setup code into a _make_test_dir()
helper function in regrtest, then have both regrtest and test.__main__
call it.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list