kopia lustrzana https://github.com/micropython/micropython-lib
unittest: Factor out adhoc run_class() method.
TODO: Look for compliant analog.pull/118/head
rodzic
4963237025
commit
5437db4638
|
@ -25,14 +25,19 @@ class TestCase:
|
||||||
raise
|
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__"):
|
def main(module="__main__"):
|
||||||
m = __import__(module)
|
m = __import__(module)
|
||||||
for tn in dir(m):
|
for tn in dir(m):
|
||||||
c = getattr(m, tn)
|
c = getattr(m, tn)
|
||||||
if isinstance(c, object) and issubclass(c, TestCase):
|
if isinstance(c, object) and issubclass(c, TestCase):
|
||||||
o = c()
|
run_class(c)
|
||||||
for name in dir(o):
|
|
||||||
if name.startswith("test"):
|
|
||||||
m = getattr(o, name)
|
|
||||||
m()
|
|
||||||
print(name, "...ok")
|
|
||||||
|
|
Ładowanie…
Reference in New Issue