unittest: TestSuite: Add run() method.

For CPython compatibility.

Signed-off-by: Paul Sokolovsky <pfalcon@users.sourceforge.net>
pull/488/head
Paul Sokolovsky 2020-11-15 11:52:23 +03:00 zatwierdzone przez Andrew Leech
rodzic 04dce89790
commit 2c0b508e4d
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -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: