summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-04-30 14:45:08 -0700
committerGitHub <noreply@github.com>2020-04-30 23:45:08 +0200
commit3480e1b05f3e98744a1b6aa6fe286caac86e6bbd (patch)
tree4c3dc33e7102e60b3a49555a3c91c4a7493d1556 /scripts
parent5f56983c2195ff6c20c8066749fa8b28d47dbd2e (diff)
downloadpsutil-3480e1b05f3e98744a1b6aa6fe286caac86e6bbd.tar.gz
Per-test file cleanup and new PsutilTestCase (#1743)
Test files/dirs are now removed after each test. when invoked via self.get_testfn(). Until now test files were stored in a global variable and were removed at process exit, via atexit.register(), but this didn't work with parallel tests because the fork()ed workers use os._exit(0), preventing cleanup functions to run. All test classes now inherit from PsutilTestCase class, which provides the most important methods requiring an automatic cleanup (get_test_subprocess() and others).
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/internal/winmake.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py
index f39d45ac..eebd1692 100755
--- a/scripts/internal/winmake.py
+++ b/scripts/internal/winmake.py
@@ -31,7 +31,7 @@ if APPVEYOR:
PYTHON = sys.executable
else:
PYTHON = os.getenv('PYTHON', sys.executable)
-TEST_SCRIPT = 'psutil\\tests\\runner.py'
+RUNNER_PY = 'psutil\\tests\\runner.py'
GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
PY3 = sys.version_info[0] == 3
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -397,13 +397,11 @@ def lint():
sh("%s -m flake8 %s" % (PYTHON, py_files), nolog=True)
-def test(script=TEST_SCRIPT):
+def test(name=""):
"""Run tests"""
install()
test_setup()
- cmdline = "%s %s" % (PYTHON, script)
- safe_print(cmdline)
- sh(cmdline)
+ sh("%s %s %s" % (PYTHON, RUNNER_PY, name))
def coverage():
@@ -411,7 +409,7 @@ def coverage():
# Note: coverage options are controlled by .coveragerc file
install()
test_setup()
- sh("%s -m coverage run %s" % (PYTHON, TEST_SCRIPT))
+ sh("%s -m coverage run %s" % (PYTHON, RUNNER_PY))
sh("%s -m coverage report" % PYTHON)
sh("%s -m coverage html" % PYTHON)
sh("%s -m webbrowser -t htmlcov/index.html" % PYTHON)
@@ -477,8 +475,7 @@ def test_failed():
"""Re-run tests which failed on last run."""
install()
test_setup()
- sh('%s -c "import psutil.tests.runner as r; r.run(last_failed=True)"' % (
- PYTHON))
+ sh("%s %s --last-failed" % (PYTHON, RUNNER_PY))
def test_memleaks():