summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-02-02 13:10:24 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-02-02 13:10:24 +0100
commit547a6a6ff4be8bff9d14fca24b68a95a96743f1b (patch)
tree1d1c48cfebeb542b07c7f6a0ecd03fadaf6ec992
parentd1e46249b769a44cc58c0da7b2c9749650aa5138 (diff)
downloadpsutil-547a6a6ff4be8bff9d14fca24b68a95a96743f1b.tar.gz
refactor test runner
-rwxr-xr-xpsutil/tests/runner.py34
-rwxr-xr-xsetup.py2
2 files changed, 24 insertions, 12 deletions
diff --git a/psutil/tests/runner.py b/psutil/tests/runner.py
index 1c282f68..88bcd620 100755
--- a/psutil/tests/runner.py
+++ b/psutil/tests/runner.py
@@ -13,15 +13,25 @@ from psutil.tests import unittest
from psutil.tests import VERBOSITY
-HERE = os.path.abspath(os.path.dirname(__file__))
-testmodules = [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')]
-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()
-sys.exit(0 if success else 1)
+def get_suite():
+ HERE = os.path.abspath(os.path.dirname(__file__))
+ testmodules = [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')]
+ 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))
+ return suite
+
+
+def main():
+ # run tests
+ result = unittest.TextTestRunner(verbosity=VERBOSITY).run(get_suite())
+ success = result.wasSuccessful()
+ sys.exit(0 if success else 1)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/setup.py b/setup.py
index 01543bee..47772da9 100755
--- a/setup.py
+++ b/setup.py
@@ -270,6 +270,8 @@ def main():
license='BSD',
packages=['psutil', 'psutil.tests'],
ext_modules=extensions,
+ test_suite="psutil.tests.runner.get_suite",
+ tests_require=['ipaddress', 'mock', 'unittest2'],
# see: python setup.py register --list-classifiers
classifiers=[
'Development Status :: 5 - Production/Stable',