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