Make case-discovery code cleaner and more flexible
This commit is contained in:
parent
0cdbf5ba7d
commit
b3c0235486
2 changed files with 9 additions and 7 deletions
|
@ -104,13 +104,17 @@ class AdvancedMailFilterE2ETest(unittest.TestCase):
|
|||
logging.info('Closing the server (SIGINT): %s', (cls.server))
|
||||
_interrupt(cls.server)
|
||||
|
||||
def case_range(self):
|
||||
return range(1, self.config.getint('tests', 'cases') + 1)
|
||||
def case_names(self):
|
||||
def is_test_case(case_name: str) -> bool:
|
||||
return case_name.startswith('case-')
|
||||
|
||||
for tc in filter(is_test_case, self.config.sections()):
|
||||
yield tc
|
||||
|
||||
def test_all_cases(self):
|
||||
for case_no in self.case_range():
|
||||
with self.subTest(case_no=case_no):
|
||||
self._execute_case(self.config, case_name=f'case-{case_no}')
|
||||
for case_name in self.case_names():
|
||||
with self.subTest(case=case_name):
|
||||
self._execute_case(self.config, case_name=case_name)
|
||||
|
||||
def _execute_case(self, config, case_name):
|
||||
logging.info(f"Executing case {case_name}")
|
||||
|
|
|
@ -29,8 +29,6 @@ keys: test/keyhome
|
|||
certs: test/certs
|
||||
|
||||
[tests]
|
||||
# Number of "test-*" sections in this file, describing test cases.
|
||||
cases: 21
|
||||
e2e_log: test/logs/e2e.log
|
||||
e2e_log_format: %(asctime)s %(pathname)s:%(lineno)d %(levelname)s [%(funcName)s] %(message)s
|
||||
e2e_log_datefmt: %Y-%m-%d %H:%M:%S
|
||||
|
|
Loading…
Reference in a new issue