summaryrefslogtreecommitdiff
path: root/psutil/tests
diff options
context:
space:
mode:
Diffstat (limited to 'psutil/tests')
-rw-r--r--psutil/tests/__init__.py3
-rwxr-xr-xpsutil/tests/__main__.py4
-rwxr-xr-xpsutil/tests/runner.py42
-rwxr-xr-xpsutil/tests/test_aix.py4
-rwxr-xr-xpsutil/tests/test_bsd.py4
-rwxr-xr-xpsutil/tests/test_connections.py4
-rwxr-xr-xpsutil/tests/test_contracts.py4
-rwxr-xr-xpsutil/tests/test_linux.py4
-rwxr-xr-xpsutil/tests/test_memory_leaks.py4
-rwxr-xr-xpsutil/tests/test_misc.py4
-rwxr-xr-xpsutil/tests/test_osx.py4
-rwxr-xr-xpsutil/tests/test_posix.py4
-rwxr-xr-xpsutil/tests/test_process.py4
-rwxr-xr-xpsutil/tests/test_sunos.py4
-rwxr-xr-xpsutil/tests/test_system.py4
-rwxr-xr-xpsutil/tests/test_unicode.py4
-rwxr-xr-xpsutil/tests/test_windows.py4
17 files changed, 48 insertions, 57 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index 0a29c59d..13c87c65 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -80,8 +80,7 @@ __all__ = [
'ThreadTask'
# test utils
'unittest', 'skip_on_access_denied', 'skip_on_not_implemented',
- 'retry_before_failing', 'run_test_module_by_name', 'get_suite',
- 'run_suite',
+ 'retry_before_failing',
# install utils
'install_pip', 'install_test_deps',
# fs utils
diff --git a/psutil/tests/__main__.py b/psutil/tests/__main__.py
index 3180c279..68710d44 100755
--- a/psutil/tests/__main__.py
+++ b/psutil/tests/__main__.py
@@ -21,7 +21,7 @@ except ImportError:
from urllib2 import urlopen
from psutil.tests import PYTHON_EXE
-from psutil.tests.runner import run_suite
+from psutil.tests.runner import run
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -88,7 +88,7 @@ def main():
except ImportError:
sys.exit("%r lib is not installed; run %s -m psutil.tests "
"--install-deps" % (dep, PYTHON_EXE))
- run_suite()
+ run()
main()
diff --git a/psutil/tests/runner.py b/psutil/tests/runner.py
index 33f96000..f555e4b0 100755
--- a/psutil/tests/runner.py
+++ b/psutil/tests/runner.py
@@ -88,35 +88,27 @@ def setup_tests():
psutil._psplatform.cext.set_testing()
-def get_suite():
- testmods = [os.path.splitext(x)[0] for x in os.listdir(HERE)
- if x.endswith('.py') and x.startswith('test_') and not
- x.startswith('test_memory_leaks')]
- if "WHEELHOUSE_UPLOADER_USERNAME" in os.environ:
- testmods = [x for x in testmods if not x.endswith((
- "osx", "posix", "linux"))]
+def get_suite(name=None):
suite = unittest.TestSuite()
- for tm in testmods:
- # ...so that the full test paths are printed on screen
- tm = "psutil.tests.%s" % tm
- suite.addTest(unittest.defaultTestLoader.loadTestsFromName(tm))
+ if name is None:
+ testmods = [os.path.splitext(x)[0] for x in os.listdir(HERE)
+ if x.endswith('.py') and x.startswith('test_') and not
+ x.startswith('test_memory_leaks')]
+ if "WHEELHOUSE_UPLOADER_USERNAME" in os.environ:
+ testmods = [x for x in testmods if not x.endswith((
+ "osx", "posix", "linux"))]
+ for tm in testmods:
+ # ...so that the full test paths are printed on screen
+ tm = "psutil.tests.%s" % tm
+ suite.addTest(unittest.defaultTestLoader.loadTestsFromName(tm))
+ else:
+ name = os.path.splitext(os.path.basename(name))[0]
+ suite.addTest(unittest.defaultTestLoader.loadTestsFromName(name))
return suite
-def run_test_module_by_name(name):
- # testmodules = [os.path.splitext(x)[0] for x in os.listdir(HERE)
- # if x.endswith('.py') and x.startswith('test_')]
- setup_tests()
- name = os.path.splitext(os.path.basename(name))[0]
- suite = unittest.TestSuite()
- suite.addTest(unittest.defaultTestLoader.loadTestsFromName(name))
- result = ColouredRunner(verbosity=VERBOSITY).run(suite)
- success = result.wasSuccessful()
- sys.exit(0 if success else 1)
-
-
-def run_suite():
+def run(name=None):
setup_tests()
- result = ColouredRunner(verbosity=VERBOSITY).run(get_suite())
+ result = ColouredRunner(verbosity=VERBOSITY).run(get_suite(name))
success = result.wasSuccessful()
sys.exit(0 if success else 1)
diff --git a/psutil/tests/test_aix.py b/psutil/tests/test_aix.py
index 5294493b..1757e3e5 100755
--- a/psutil/tests/test_aix.py
+++ b/psutil/tests/test_aix.py
@@ -117,5 +117,5 @@ class AIXSpecificTestCase(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_bsd.py b/psutil/tests/test_bsd.py
index d06bfef9..f1b5775a 100755
--- a/psutil/tests/test_bsd.py
+++ b/psutil/tests/test_bsd.py
@@ -549,5 +549,5 @@ class NetBSDSpecificTestCase(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py
index 2a79338e..68eea784 100755
--- a/psutil/tests/test_connections.py
+++ b/psutil/tests/test_connections.py
@@ -522,5 +522,5 @@ class TestMisc(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py
index 892ffb9b..08e9e9b8 100755
--- a/psutil/tests/test_contracts.py
+++ b/psutil/tests/test_contracts.py
@@ -653,5 +653,5 @@ class TestFetchAllProcesses(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index de96f049..eb3e560d 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -2079,5 +2079,5 @@ class TestUtils(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_memory_leaks.py b/psutil/tests/test_memory_leaks.py
index f90e8377..ed3a77fe 100755
--- a/psutil/tests/test_memory_leaks.py
+++ b/psutil/tests/test_memory_leaks.py
@@ -606,5 +606,5 @@ class TestModuleFunctionsLeaks(TestMemLeak):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index 36f8bf06..29e1e41e 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -1053,5 +1053,5 @@ class TestOtherUtils(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_osx.py b/psutil/tests/test_osx.py
index 232b5a71..0e6ed67c 100755
--- a/psutil/tests/test_osx.py
+++ b/psutil/tests/test_osx.py
@@ -290,5 +290,5 @@ class TestSystemAPIs(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py
index 88506b9a..8f7fbf51 100755
--- a/psutil/tests/test_posix.py
+++ b/psutil/tests/test_posix.py
@@ -436,5 +436,5 @@ class TestSystemAPIs(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index a4d49ed4..baa3e346 100755
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -1607,5 +1607,5 @@ class TestPopen(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_sunos.py b/psutil/tests/test_sunos.py
index 75b99fee..94405d41 100755
--- a/psutil/tests/test_sunos.py
+++ b/psutil/tests/test_sunos.py
@@ -41,5 +41,5 @@ class SunOSSpecificTestCase(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 43de8b99..00a38586 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -867,5 +867,5 @@ class TestSystemAPIs(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py
index a015c896..f7115e3d 100755
--- a/psutil/tests/test_unicode.py
+++ b/psutil/tests/test_unicode.py
@@ -366,5 +366,5 @@ class TestNonFSAPIS(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index 00d0fece..a9aeba8e 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -864,5 +864,5 @@ class TestServices(unittest.TestCase):
if __name__ == '__main__':
- from psutil.tests.runner import run_test_module_by_name
- run_test_module_by_name(__file__)
+ from psutil.tests.runner import run
+ run(__file__)