def test(*args):
"""
Run unit tests. Only works inside source repo, not when installed.
"""
# unittest.main doesn't work because this isn't a module
# so we'll do it ourselves
print("-" * 79)
for clsname, cls in sorted(globals().items()):
if clsname.startswith("Test") and isinstance(cls, type):
o = cls()
for fnname in sorted(dir(o)):
if fnname.startswith("test"):
fn = getattr(o, fnname)
if callable(fn):
fn()
print()
print(tests_run, "tests passed.")
评论列表
文章目录