def list_tags(option, opt, value, parser, *args, **kwargs):
alltags = []
testsuites = []
testdir, testfiles = gettestfiles(os.path.join
(os.path.dirname(__file__), ".."))
testloader = unittest.defaultTestLoader
for test in testfiles:
try:
testmod = os.path.splitext(test)[0]
fp, pathname, descr = imp.find_module(testmod, [testdir, ])
package = imp.load_module(testmod, fp, pathname, descr)
try:
testsuites.append(loadtests_frompkg(package, testloader))
except:
printerror()
except:
pass
for suite in testsuites:
for test in suite:
if hasattr(test, "__tags__"):
tags = getattr(test, "__tags__")
for tag in tags:
if tag not in alltags:
alltags.append(tag)
print(alltags)
sys.exit()
评论列表
文章目录