summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-11-24 10:37:13 -0800
committerJohn L. Villalovos <john@sodarock.com>2021-11-24 10:47:33 -0800
commita2e838ff4ffb19d192ab0d2b61d6cedded37fc69 (patch)
treeb91d393484364f5b56380cb58a9af5867e3b5481
parent7ba5995ed472997e6bf98e8ae58107af307a5615 (diff)
downloadgitlab-jlvillal/reduce_meta_tests.tar.gz
chore: remove duplicate/no-op tests from meta/test_ensure_type_hintsjlvillal/reduce_meta_tests
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
-rw-r--r--tests/meta/test_ensure_type_hints.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/meta/test_ensure_type_hints.py b/tests/meta/test_ensure_type_hints.py
index 7a351ec..8c1c060 100644
--- a/tests/meta/test_ensure_type_hints.py
+++ b/tests/meta/test_ensure_type_hints.py
@@ -30,7 +30,7 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
if module.startswith("gitlab.v4.objects"):
excluded_modules.add(module)
- class_info_list = []
+ class_info_set = set()
for module_name, module_value in inspect.getmembers(gitlab.v4.objects):
if not inspect.ismodule(module_value):
# We only care about the modules
@@ -49,9 +49,10 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
if module_name == "gitlab.base":
continue
- class_info_list.append((class_name, class_value))
-
- metafunc.parametrize("class_info", class_info_list)
+ if not class_name.endswith("Manager"):
+ continue
+ class_info_set.add((class_name, class_value))
+ metafunc.parametrize("class_info", class_info_set)
class TestTypeHints: