Commit 9ea3c2cb authored by jvoisin's avatar jvoisin

Improves the way tests are handled with `python setup.py test`

parent a71bbcaf
......@@ -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',
......
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment