From 8d2de3c47b37d6f99c80e17568e9601b843a1b75 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Thu, 29 Oct 2009 07:29:19 +0000 Subject: [PATCH] Introduce DebugTextTestRunner to extend TextTestRunner instead of wrapping test runs. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30090 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/tests/runUnitTest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/product/ERP5Type/tests/runUnitTest.py b/product/ERP5Type/tests/runUnitTest.py index 09f551a8ff..8bd4777f8e 100755 --- a/product/ERP5Type/tests/runUnitTest.py +++ b/product/ERP5Type/tests/runUnitTest.py @@ -332,14 +332,20 @@ def runUnitTestList(test_list, verbosity=1, debug=0): # Hack the profiler to run only specified test methods, and wrap results when # running in debug mode. if not dummy_test: + if debug: + class DebugTextTestRunner(backportUnittest.TextTestRunner): + def _makeResult(self): + result = super(DebugTextTestRunner, self)._makeResult() + return DebugTestResult(result) + + TestRunner = DebugTextTestRunner + test_method_list = os.environ.get('run_only', '').split(',') def wrapped_run(run_orig): # wrap the method that run the test to run test method only if its name # matches the run_only spec and to provide post mortem debugging facility def run(self, result=None): - if debug and result: - result = DebugTestResult(result) if not test_method_list: return run_orig(self, result) test_method_name = self.id().rsplit('.', 1)[-1] -- 2.30.9