[Pkg-privacy-commits] [mat] 18/68: Improves the way tests are handled with `python setup.py test`

Sascha Steinbiss sascha at steinbiss.name
Sun Jan 3 12:32:39 UTC 2016


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository mat.

commit 9ea3c2cbc456bfa9a903eaa0ed6a42a34d12e1c2
Author: jvoisin <julien.voisin at dustri.org>
Date:   Wed Nov 25 18:14:17 2015 +0100

    Improves the way tests are handled with `python setup.py test`
---
 setup.py     |  6 ++----
 test/test.py | 25 +++++++++++++++++--------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/setup.py b/setup.py
index 8da1bfb..6d4e320 100755
--- a/setup.py
+++ b/setup.py
@@ -23,11 +23,9 @@ class PyTest(Command):
         pass
 
     def run(self):
-        import subprocess
-        import sys
         os.chdir('test')
-        errno = subprocess.call([sys.executable, 'test.py', '--local'])
-        raise SystemExit(errno)
+        import test
+        test.test.run_all_tests()
 
 setup(
     name='MAT',
diff --git a/test/test.py b/test/test.py
index bd688c1..2072e18 100644
--- a/test/test.py
+++ b/test/test.py
@@ -75,9 +75,24 @@ class MATTest(unittest.TestCase):
         shutil.rmtree(self.tmpdir)
 
 
-if __name__ == '__main__':
+def run_all_tests():
+    """
+    This method will run all tests, both for cli and lib.
+    The imports of clitest and libtest are done here because
+    of dependencie on the IS_LOCAL variable.
+
+    If set to true, the tests will be done on the _local_ instance
+    of MAT, else, on the _system-wide_ one.
+    """
     import clitest
     import libtest
+    SUITE = unittest.TestSuite()
+    SUITE.addTests(clitest.get_tests())
+    SUITE.addTests(libtest.get_tests())
+
+    return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful()
+
+if __name__ == '__main__':
     import argparse
 
     parser = argparse.ArgumentParser(description='MAT testsuite')
@@ -94,10 +109,4 @@ if __name__ == '__main__':
         print('Please specify either --local or --system')
         sys.exit(1)
 
-
-    SUITE = unittest.TestSuite()
-    SUITE.addTests(clitest.get_tests())
-    SUITE.addTests(libtest.get_tests())
-
-    ret = unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful()
-    sys.exit(ret is False)
+    sys.exit(run_all_tests() is False)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/mat.git



More information about the Pkg-privacy-commits mailing list