summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2015-11-25 18:14:17 +0100
committerjvoisin2015-11-26 15:47:30 +0100
commit9ea3c2cbc456bfa9a903eaa0ed6a42a34d12e1c2 (patch)
treef7518bb32a47b72aa068f95919aefe020fca333a
parenta71bbcaf57be3076cb7bd38d07cf13e71fcbe611 (diff)
Improves the way tests are handled with `python setup.py test`
-rwxr-xr-xsetup.py6
-rw-r--r--test/test.py25
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):
23 pass 23 pass
24 24
25 def run(self): 25 def run(self):
26 import subprocess
27 import sys
28 os.chdir('test') 26 os.chdir('test')
29 errno = subprocess.call([sys.executable, 'test.py', '--local']) 27 import test
30 raise SystemExit(errno) 28 test.test.run_all_tests()
31 29
32setup( 30setup(
33 name='MAT', 31 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):
75 shutil.rmtree(self.tmpdir) 75 shutil.rmtree(self.tmpdir)
76 76
77 77
78if __name__ == '__main__': 78def run_all_tests():
79 """
80 This method will run all tests, both for cli and lib.
81 The imports of clitest and libtest are done here because
82 of dependencie on the IS_LOCAL variable.
83
84 If set to true, the tests will be done on the _local_ instance
85 of MAT, else, on the _system-wide_ one.
86 """
79 import clitest 87 import clitest
80 import libtest 88 import libtest
89 SUITE = unittest.TestSuite()
90 SUITE.addTests(clitest.get_tests())
91 SUITE.addTests(libtest.get_tests())
92
93 return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful()
94
95if __name__ == '__main__':
81 import argparse 96 import argparse
82 97
83 parser = argparse.ArgumentParser(description='MAT testsuite') 98 parser = argparse.ArgumentParser(description='MAT testsuite')
@@ -94,10 +109,4 @@ if __name__ == '__main__':
94 print('Please specify either --local or --system') 109 print('Please specify either --local or --system')
95 sys.exit(1) 110 sys.exit(1)
96 111
97 112 sys.exit(run_all_tests() is False)
98 SUITE = unittest.TestSuite()
99 SUITE.addTests(clitest.get_tests())
100 SUITE.addTests(libtest.get_tests())
101
102 ret = unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful()
103 sys.exit(ret is False)