From 9ea3c2cbc456bfa9a903eaa0ed6a42a34d12e1c2 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 25 Nov 2015 18:14:17 +0100 Subject: 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) -- cgit v1.3