kopia lustrzana https://github.com/micropython/micropython-lib
unittest: Add support for setUp() and tearDown().
rodzic
923bbc4d96
commit
bef746c1d0
|
@ -54,11 +54,15 @@ def skipUnless(cond, msg):
|
||||||
# TODO: Uncompliant
|
# TODO: Uncompliant
|
||||||
def run_class(c):
|
def run_class(c):
|
||||||
o = c()
|
o = c()
|
||||||
|
set_up = getattr(o, "setUp", lambda: None)
|
||||||
|
tear_down = getattr(o, "tearDown", lambda: None)
|
||||||
for name in dir(o):
|
for name in dir(o):
|
||||||
if name.startswith("test"):
|
if name.startswith("test"):
|
||||||
m = getattr(o, name)
|
m = getattr(o, name)
|
||||||
try:
|
try:
|
||||||
|
set_up()
|
||||||
m()
|
m()
|
||||||
|
tear_down()
|
||||||
print(name, "...ok")
|
print(name, "...ok")
|
||||||
except SkipTest as e:
|
except SkipTest as e:
|
||||||
print(name, "...skipped:", e.args[0])
|
print(name, "...skipped:", e.args[0])
|
||||||
|
|
Ładowanie…
Reference in New Issue