test-bots: Extract test discovery out of conditional.
This (re?)-enables exclusion of bot names from eg. `test-bots`.
This commit is contained in:
parent
a5307b3771
commit
210caa4a60
|
@ -69,20 +69,22 @@ def main():
|
||||||
cov.load()
|
cov.load()
|
||||||
cov.start()
|
cov.start()
|
||||||
|
|
||||||
loader = unittest.defaultTestLoader
|
|
||||||
top_level = "zulip_bots/zulip_bots/bots/"
|
|
||||||
if options.bots_to_test:
|
if options.bots_to_test:
|
||||||
bots_to_test = filter(lambda bot: bot not in options.exclude,
|
bots_to_test = filter(lambda bot: bot not in options.exclude,
|
||||||
options.bots_to_test)
|
options.bots_to_test)
|
||||||
# Should add a check here that __init__.py is absent if test_*.py is present?
|
|
||||||
test_suites = [loader.discover(top_level + name, top_level_dir=top_level)
|
|
||||||
for name in bots_to_test]
|
|
||||||
else:
|
else:
|
||||||
# Codecov seems to work only when using loader.discover. It failed to
|
bots_to_test = filter(lambda bot: bot not in options.exclude,
|
||||||
# capture line executions for functions like loader.loadTestFromModule
|
available_bots)
|
||||||
# or loader.loadTestFromNames.
|
|
||||||
test_suites = [loader.discover(top_level + name, top_level_dir=top_level)
|
# Should add a check here that __init__.py is absent if test_*.py is present?
|
||||||
for name in available_bots]
|
|
||||||
|
# Codecov seems to work only when using loader.discover. It failed to
|
||||||
|
# capture line executions for functions like loader.loadTestFromModule
|
||||||
|
# or loader.loadTestFromNames.
|
||||||
|
top_level = "zulip_bots/zulip_bots/bots/"
|
||||||
|
loader = unittest.defaultTestLoader
|
||||||
|
test_suites = [loader.discover(top_level + name, top_level_dir=top_level)
|
||||||
|
for name in bots_to_test]
|
||||||
|
|
||||||
def filter_tests(tests):
|
def filter_tests(tests):
|
||||||
# type: (Union[TestSuite, TestCase]) -> TestSuite
|
# type: (Union[TestSuite, TestCase]) -> TestSuite
|
||||||
|
|
Loading…
Reference in a new issue