From 93b7bbebd96c1cca24a53659657033d621e5c1f4 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 9 Oct 2011 19:21:54 -0700 Subject: [PATCH] tests/__init__: return int from main() --- pym/portage/tests/__init__.py | 13 ++++++++----- pym/portage/tests/runTests | 4 +--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py index fedb7e605..492ece44b 100644 --- a/pym/portage/tests/__init__.py +++ b/pym/portage/tests/__init__.py @@ -34,15 +34,18 @@ def main(): testsubdir = os.path.basename(mydir) for name in getTestNames(mydir): print("%s/%s/%s.py" % (testdir, testsubdir, name)) - sys.exit(0) + return os.EX_OK if len(args) > 1: suite.addTests(getTestFromCommandLine(args[1:], basedir)) - return TextTestRunner(verbosity=2).run(suite) + else: + for mydir in getTestDirs(basedir): + suite.addTests(getTests(os.path.join(basedir, mydir), basedir)) - for mydir in getTestDirs(basedir): - suite.addTests(getTests(os.path.join(basedir, mydir), basedir) ) - return TextTestRunner(verbosity=2).run(suite) + result = TextTestRunner(verbosity=2).run(suite) + if not result.wasSuccessful(): + return 1 + return os.EX_OK def my_import(name): mod = __import__(name) diff --git a/pym/portage/tests/runTests b/pym/portage/tests/runTests index 146f7d4ac..4c1008708 100755 --- a/pym/portage/tests/runTests +++ b/pym/portage/tests/runTests @@ -41,6 +41,4 @@ del path if __name__ == "__main__": - result = tests.main() - if not result.wasSuccessful(): - sys.exit(1) + sys.exit(tests.main()) -- 2.26.2