diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-05-14 23:37:02 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-05-14 23:37:02 +0200 |
commit | 868e2a7bb86bc7586aa6f686d8f5af41fa3a0a92 (patch) | |
tree | 56bd1521056fae6429c109306cf20332a95dd1e2 /setup.py | |
parent | fb361792d73a674fa9444fff183f1ed686ffaa59 (diff) | |
download | semantic-version-868e2a7bb86bc7586aa6f686d8f5af41fa3a0a92.tar.gz |
Improve test runner
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -30,12 +30,14 @@ class test(cmd.Command): ('test-suite=', None, "A test suite to run (defaults to 'tests')"), ] + DEFAULT_TEST_SUITE = 'tests' + def initialize_options(self): self.test_runner = None self.test_suite = None def finalize_options(self): - self.ensure_string('test_suite', 'tests') + self.ensure_string('test_suite', self.DEFAULT_TEST_SUITE) def run(self): """Run the test suite.""" @@ -47,7 +49,12 @@ class test(cmd.Command): ex_path = sys.path sys.path.insert(0, os.path.join(root_dir, 'src')) - suite = unittest.TestLoader().loadTestsFromName(self.test_suite) + loader = unittest.defaultTestLoader + + if self.test_suite != self.DEFAULT_TEST_SUITE: + suite = loader.loadTestsFromName(self.test_suite) + else: + suite = loader.discover(self.test_suite) unittest.TextTestRunner(verbosity=verbosity).run(suite) sys.path = ex_path |