tests/__init__: return int from main()
authorZac Medico <zmedico@gentoo.org>
Mon, 10 Oct 2011 02:21:54 +0000 (19:21 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 10 Oct 2011 02:21:54 +0000 (19:21 -0700)
pym/portage/tests/__init__.py
pym/portage/tests/runTests

index fedb7e605a4ab52da9456f74b58e7828c2daeb3d..492ece44bfbb6398eca5cd5c5d5c1dd740b4fcc8 100644 (file)
@@ -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)
index 146f7d4acac8cc81c02d9176a1a766dffe484d35..4c10087084183233959772fbb618261362d51104 100755 (executable)
@@ -41,6 +41,4 @@ del path
 
 
 if __name__ == "__main__":
-       result = tests.main()
-       if not result.wasSuccessful():
-               sys.exit(1)
+       sys.exit(tests.main())