From 868e2a7bb86bc7586aa6f686d8f5af41fa3a0a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 14 May 2012 23:37:02 +0200 Subject: Improve test runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Barrois --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 84c0040..2f37b5f 100755 --- a/setup.py +++ b/setup.py @@ -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 -- cgit v1.2.1