bot tests: Adjust TestCase inheritance to avoid need to skip/filter.
Previously the test-bots script filtered out base-class tests from BotTestCase. With this change, BotTestCase continues to inherit from unittest.TestCase, but the default test_* methods previously in this class are now in a new DefaultTests class, which does not. Instead, each bot needs to inherit from BotTestCase and DefaultTests *explicitly*. This avoids the need to filter out the base-class tests, which simplifies the test-bots script, and may ease any migration to eg. pytest. The DefaultTests class does require some non-implemented methods which BotTestCase provides.
This commit is contained in:
parent
c636a5ac49
commit
6cdb83ce72
43 changed files with 105 additions and 102 deletions
|
@ -95,19 +95,6 @@ def main():
|
|||
if options.error_on_no_init:
|
||||
sys.exit(1)
|
||||
|
||||
def filter_tests(tests):
|
||||
# type: (Union[TestSuite, TestCase]) -> TestSuite
|
||||
filtered_tests = TestSuite()
|
||||
for test in tests:
|
||||
if isinstance(test, TestCase):
|
||||
# Exclude test base class from being tested.
|
||||
if test.__class__.__name__ != 'BotTestCase':
|
||||
filtered_tests.addTest(test)
|
||||
else:
|
||||
filtered_tests.addTest(filter_tests(test))
|
||||
return filtered_tests
|
||||
test_suites = filter_tests(test_suites)
|
||||
|
||||
suite = unittest.TestSuite(test_suites)
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
result = runner.run(suite)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue