unittest: Rewrite .main() to be compliant re: 1st arg.

asyncio-segfault
Paul Sokolovsky 2014-04-04 21:41:33 +03:00
rodzic 1729f1c7fa
commit 525487137b
1 zmienionych plików z 12 dodań i 10 usunięć

Wyświetl plik

@ -25,13 +25,15 @@ class TestCase:
raise
# Warning: this is not compliant, but at least an example of test
# runner until we have globals()
def main(test_classes):
for c in test_classes:
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)
# workaround for isinstance(c, object) not working
if type(c) is type(object) and issubclass(c, TestCase):
o = c()
for name in dir(o):
if name.startswith("test"):
m = getattr(o, name)
m()
print(name, "...ok")