Skip to content

Commit a2e838f

Browse files
chore: remove duplicate/no-op tests from meta/test_ensure_type_hints
Before we were generating 725 tests for the meta/test_ensure_type_hints.py tests. Which isn't a huge concern as it was fairly fast. But when we had a failure we would usually get two failures for each problem as the same test was being run multiple times. Changed it so that: 1. Don't add tests that are not for *Manager classes 2. Use a set so that we don't have duplicate tests. After doing that our generated test count in meta/test_ensure_type_hints.py went from 725 to 178 tests. To determine the test count the following command was run: $ tox -e py39 -- -k test_ensure_type_hints
1 parent 7ba5995 commit a2e838f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/meta/test_ensure_type_hints.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
3030
if module.startswith("gitlab.v4.objects"):
3131
excluded_modules.add(module)
3232

33-
class_info_list = []
33+
class_info_set = set()
3434
for module_name, module_value in inspect.getmembers(gitlab.v4.objects):
3535
if not inspect.ismodule(module_value):
3636
# We only care about the modules
@@ -49,9 +49,10 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
4949
if module_name == "gitlab.base":
5050
continue
5151

52-
class_info_list.append((class_name, class_value))
53-
54-
metafunc.parametrize("class_info", class_info_list)
52+
if not class_name.endswith("Manager"):
53+
continue
54+
class_info_set.add((class_name, class_value))
55+
metafunc.parametrize("class_info", class_info_set)
5556

5657

5758
class TestTypeHints:

0 commit comments

Comments
 (0)