Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3ab34cca
Commit
3ab34cca
authored
Dec 03, 2010
by
Michael Foord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out common code from lib/test/__main__.py and lib/test/regrtest.py into a function.
parent
61561529
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
47 deletions
+24
-47
Lib/test/__main__.py
Lib/test/__main__.py
+3
-32
Lib/test/regrtest.py
Lib/test/regrtest.py
+18
-15
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/__main__.py
View file @
3ab34cca
import
os
from
test
import
regrtest
,
support
import
sys
import
sysconfig
from
test
import
support
from
test
import
regrtest
TEMPDIR
=
regrtest
.
TEMPDIR
TEMPDIR
,
TESTCWD
=
regrtest
.
_make_temp_dir_for_build
(
regrtest
.
TEMPDIR
)
regrtest
.
TEMPDIR
=
TEMPDIR
# findtestdir() gets the dirname out of __file__, so we have to make it
# absolute before changing the working directory.
# For example __file__ may be relative when running trace or profile.
# See issue #9323.
__file__
=
os
.
path
.
abspath
(
__file__
)
# sanity check
assert
__file__
==
os
.
path
.
abspath
(
sys
.
argv
[
0
])
# 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
# 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
)
regrtest
.
TESTCWD
=
TESTCWD
regrtest
.
TESTCWD
=
TESTCWD
# Run the tests in a context manager that temporary changes the CWD to a
# Run the tests in a context manager that temporary changes the CWD to a
...
...
Lib/test/regrtest.py
View file @
3ab34cca
...
@@ -1468,6 +1468,23 @@ class _ExpectedSkips:
...
@@ -1468,6 +1468,23 @@ class _ExpectedSkips:
assert self.isvalid()
assert self.isvalid()
return self.expected
return self.expected
def _make_temp_dir_for_build(TEMPDIR):
# 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)
# 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)
return TEMPDIR, TESTCWD
if __name__ == '__main__':
if __name__ == '__main__':
# Remove regrtest.py's own directory from the module search path. Despite
# Remove regrtest.py's own directory from the module search path. Despite
...
@@ -1491,21 +1508,7 @@ if __name__ == '__main__':
...
@@ -1491,21 +1508,7 @@ if __name__ == '__main__':
# sanity check
# sanity check
assert __file__ == os.path.abspath(sys.argv[0])
assert __file__ == os.path.abspath(sys.argv[0])
# When tests are run from the Python build directory, it is best practice
TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR)
# 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)
# 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)
# Run the tests in a context manager that temporary changes the CWD to a
# 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
# temporary and writable directory. If it's not possible to create or
...
...
Misc/NEWS
View file @
3ab34cca
...
@@ -206,6 +206,9 @@ Tests
...
@@ -206,6 +206,9 @@ Tests
- regrtest.py once again ensures the test directory is removed from sys.path
- regrtest.py once again ensures the test directory is removed from sys.path
when it is invoked directly as the __main__ module
when it is invoked directly as the __main__ module
- `python -m test` can be used to run the test suite as well as
`python -m test.regrtest`.
- Issue #9424: Deprecate the `unittest.TestCase` methods `assertEquals`,
- Issue #9424: Deprecate the `unittest.TestCase` methods `assertEquals`,
`assertNotEquals`, `assertAlmostEquals`, `assertNotAlmostEquals` and `assert_`
`assertNotEquals`, `assertAlmostEquals`, `assertNotAlmostEquals` and `assert_`
and replace them with the correct methods in the Python test suite.
and replace them with the correct methods in the Python test suite.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment