summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-03-07 12:14:21 +0100
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-03-07 12:14:21 +0100
commit6873165724bb3522da25c1d6d57faba43e99cfd0 (patch)
tree51fa38bd4eaa084e1633fdba0d3a321c0229345a
parent1c4c0edb15cf5776ccfb0af3f99ea584e42c2271 (diff)
downloadlogilab-common-6873165724bb3522da25c1d6d57faba43e99cfd0.tar.gz
added a batch mode on unittest_main
-rw-r--r--testlib.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/testlib.py b/testlib.py
index 86f8aee..41bfbdd 100644
--- a/testlib.py
+++ b/testlib.py
@@ -511,7 +511,8 @@ Examples:
%(progName)s MyTestCase - run all 'test*' test methods
in MyTestCase
"""
- def __init__(self, module='__main__'):
+ def __init__(self, module='__main__', batchmode=False):
+ self.batchmode = batchmode
super(SkipAwareTestProgram, self).__init__(
module=module, testLoader=NonStrictTestLoader())
@@ -560,7 +561,9 @@ Examples:
self.pdbmode = True
if result.debuggers and self.pdbmode:
start_interactive_mode(result.debuggers, result.descrs)
- sys.exit(not result.wasSuccessful())
+ if not self.batchmode:
+ sys.exit(not result.wasSuccessful())
+ self.result = result
@@ -638,10 +641,10 @@ def capture_stderr():
return _capture('stderr')
-def unittest_main(module='__main__'):
+def unittest_main(module='__main__', batchmode=False):
"""use this functon if you want to have the same functionality
as unittest.main"""
- SkipAwareTestProgram(module)
+ return SkipAwareTestProgram(module, batchmode)
class TestSkipped(Exception):
"""raised when a test is skipped"""