summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-10-05 15:33:31 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-10-05 15:33:31 +0200
commita084e7f30eab4e9cb0dcffb01b4602bfdb6405ee (patch)
tree1558631d5d555ce9ec54f8119250abd85ba8adf2
parentacfe6b2bba2dee5e9ab19335dd22cc31d6092553 (diff)
downloadpsutil-a084e7f30eab4e9cb0dcffb01b4602bfdb6405ee.tar.gz
add hack to make unittest print full test paths; also remove nose as a dep
-rw-r--r--Makefile12
-rw-r--r--psutil/tests/__init__.py13
-rwxr-xr-xpsutil/tests/runner.py2
3 files changed, 18 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 33e078c6..3560cb2e 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,6 @@ DEPS = argparse \
ipaddress \
ipdb \
mock==1.0.1 \
- nose \
pep8 \
pyflakes \
requests \
@@ -130,15 +129,10 @@ test-memleaks: install
test-platform: install
$(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS") if getattr(psutil, x)][0])'`.py
-# Run a specific test by name; e.g. "make test-by-name disk_" will run
-# all test methods containing "disk_" in their name.
-# Requires "pip install nose".
+# Run a specific test by name, e.g.
+# make test-by-name psutil.tests.test_system.TestSystemAPIs.test_cpu_times
test-by-name: install
- @$(PYTHON) -m nose psutil/tests/*.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS))
-
-# Same as above but for test_memory_leaks.py script.
-test-memleaks-by-name: install
- @$(PYTHON) -m nose test/test_memory_leaks.py --nocapture -v -m $(filter-out $@,$(MAKECMDGOALS))
+ @$(PYTHON) -m unittest -v $(filter-out $@,$(MAKECMDGOALS))
coverage: install
# Note: coverage options are controlled by .coveragerc file
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index b6509c4c..6cbfb98d 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -517,6 +517,19 @@ def create_temp_executable_file(suffix, c_code=None):
# ===================================================================
+class TestCase(unittest.TestCase):
+
+ def __str__(self):
+ return "%s.%s.%s" % (
+ self.__class__.__module__, self.__class__.__name__,
+ self._testMethodName)
+
+
+# Hack that overrides default unittest.TestCase in order to print
+# a full path representation of the single unit tests being run.
+unittest.TestCase = TestCase
+
+
def retry_before_failing(retries=NO_RETRIES):
"""Decorator which runs a test function and retries N times before
actually failing.
diff --git a/psutil/tests/runner.py b/psutil/tests/runner.py
index c4dd88b3..1c282f68 100755
--- a/psutil/tests/runner.py
+++ b/psutil/tests/runner.py
@@ -19,6 +19,8 @@ testmodules = [os.path.splitext(x)[0] for x in os.listdir(HERE)
x.startswith('test_memory_leaks')]
suite = unittest.TestSuite()
for tm in testmodules:
+ # ...so that "make test" will print the full test paths
+ tm = "psutil.tests.%s" % tm
suite.addTest(unittest.defaultTestLoader.loadTestsFromName(tm))
result = unittest.TextTestRunner(verbosity=VERBOSITY).run(suite)
success = result.wasSuccessful()