From 2c0b508e4dcf929d96e58e62567d11ff6661e0b2 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 15 Nov 2020 11:52:23 +0300 Subject: [PATCH] unittest: TestSuite: Add run() method. For CPython compatibility. Signed-off-by: Paul Sokolovsky --- python-stdlib/unittest/unittest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python-stdlib/unittest/unittest.py b/python-stdlib/unittest/unittest.py index 5911117c..4e428204 100644 --- a/python-stdlib/unittest/unittest.py +++ b/python-stdlib/unittest/unittest.py @@ -195,12 +195,16 @@ class TestSuite: def addTest(self, cls): self._tests.append(cls) + def run(self, result): + for c in self._tests: + result.exceptions.extend(run_suite(c, result)) + return result + class TestRunner: def run(self, suite): res = TestResult() - for c in suite._tests: - res.exceptions.extend(run_suite(c, res)) + suite.run(res) print("Ran %d tests\n" % res.testsRun) if res.failuresNum > 0 or res.errorsNum > 0: