unittest: Factor out adhoc run_class() method.

TODO: Look for compliant analog.
pull/118/head
Paul Sokolovsky 2014-05-09 23:20:31 +03:00
rodzic 4963237025
commit 5437db4638
1 zmienionych plików z 11 dodań i 6 usunięć

Wyświetl plik

@ -25,14 +25,19 @@ class TestCase:
raise
# TODO: Uncompliant
def run_class(c):
o = c()
for name in dir(o):
if name.startswith("test"):
m = getattr(o, name)
m()
print(name, "...ok")
def main(module="__main__"):
m = __import__(module)
for tn in dir(m):
c = getattr(m, tn)
if isinstance(c, object) and issubclass(c, TestCase):
o = c()
for name in dir(o):
if name.startswith("test"):
m = getattr(o, name)
m()
print(name, "...ok")
run_class(c)