-tests_counter = {}
-for test_case in defs:
- name = test_case['name']
- i = tests_counter.get(name, 0)
- tests_counter[name] = i + 1
- tname = f'test_{name}_{i}' if i else f'test_{name}'
- test_method = generator(test_case, tname)
- test_method.__name__ = str(tname)
- ie_list = test_case.get('add_ie')
- test_method.add_ie = ie_list and ','.join(ie_list)
- setattr(TestDownload, test_method.__name__, test_method)
- del test_method
+def inject_tests(test_cases, label=''):
+ for test_case in test_cases:
+ name = test_case['name']
+ tname = join_nonempty('test', name, label, tests_counter[name][label], delim='_')
+ tests_counter[name][label] += 1