kopia lustrzana https://github.com/micropython/micropython-lib
unittest: Rewrite .main() to be compliant re: 1st arg.
rodzic
1729f1c7fa
commit
525487137b
|
@ -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")
|
||||||
|
|
Ładowanie…
Reference in New Issue