Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha@silbe.org>2009-09-12 22:03:11 (GMT)
committer Sascha Silbe <sascha@silbe.org>2009-09-25 19:16:18 (GMT)
commit4618345cbf7a8303ea688d7b52b0a37d91c1486e (patch)
treedffcc54a9a759125d1f6593c2719851edaee4d98
parentf5ef162e2f9d74e54ee36c43f2d660c7bae5a81e (diff)
fix support for non-doctest test cases
-rwxr-xr-xtests/runalltests.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/tests/runalltests.py b/tests/runalltests.py
index 5c438ff..c60cf1c 100755
--- a/tests/runalltests.py
+++ b/tests/runalltests.py
@@ -8,6 +8,7 @@
import doctest
import logging
import os
+import os.path
import shutil
import signal
import subprocess
@@ -63,27 +64,33 @@ def cleanup():
def test_suite(tests=None):
suite = unittest.TestSuite()
if not tests:
- tests = DOCTESTS
+ test_dir = os.path.dirname(__file__)
+ tests = [name for name in os.listdir(test_dir)
+ if name.startswith('test') and name.endswith('.py')]
+
+ tests += DOCTESTS
for test in tests:
- suite.addTest(doctest.DocFileSuite(test, optionflags=DOCTEST_OPTIONS))
+ if test.endswith('.txt'):
+ suite.addTest(doctest.DocFileSuite(test,
+ optionflags=DOCTEST_OPTIONS))
- if len(sys.argv) <= 1:
- tests = os.listdir(os.curdir)
- tests = [n[:-3] for n in tests if n.startswith('test') and
- n.endswith('.py')]
+ elif test.endswith('.py'):
+ m = __import__(test[:-3])
+ if hasattr(m, 'suite'):
+ suite.addTest(m.suite())
- for test in tests:
- module = __import__(test)
- if hasattr(module, 'test_suite'):
- suite.addTest(module.test_suite())
return suite
def run_tests(tests):
runner = unittest.TextTestRunner(verbosity=1)
suite = test_suite(tests)
- runner.run(suite)
+ result = runner.run(suite)
+ if result.wasSuccessful():
+ return 0
+ else:
+ return 10
def main(my_name, arguments):
@@ -99,8 +106,7 @@ def main(my_name, arguments):
cleanup()
else:
- run_tests(arguments[1:])
- return 0
+ return run_tests(arguments[1:])
if __name__ == "__main__":