Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2f59f4

Browse files
chore: remove duplicate/no-op tests from meta/test_ensure_type_hints
Before we were generating 725 tests for themeta/test_ensure_type_hints.py tests. Which isn't a huge concern asit was fairly fast. But when we had a failure we would usually get twofailures for each problem as the same test was being run multipletimes.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 inmeta/test_ensure_type_hints.py went from 725 to 178 tests.Additionally removed the parsing of `pyproject.toml` to generate filesto ignore as we have finished adding type-hints to all files ingitlab/v4/objects/. This also means we no longer use the toml libraryso remove installation of `types-toml`.To determine the test count the following command was run: $ tox -e py39 -- -k test_ensure_type_hints
1 parent7ba5995 commita2f59f4

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

‎requirements-lint.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ pytest
66
types-PyYAML==6.0.1
77
types-requests==2.26.0
88
types-setuptools==57.4.3
9-
types-toml==0.10.1

‎tests/meta/test_ensure_type_hints.py‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
fromtypingimportTuple,Type
99

1010
import_pytest
11-
importtoml
1211

1312
importgitlab.mixins
1413
importgitlab.v4.objects
@@ -18,20 +17,8 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
1817
"""Find all of the classes in gitlab.v4.objects and pass them to our test
1918
function"""
2019

21-
# Ignore any modules that we are ignoring in our pyproject.toml
22-
excluded_modules=set()
23-
withopen("pyproject.toml","r")asin_file:
24-
pyproject=toml.load(in_file)
25-
overrides=pyproject.get("tool", {}).get("mypy", {}).get("overrides", [])
26-
foroverrideinoverrides:
27-
ifnotoverride.get("ignore_errors"):
28-
continue
29-
formoduleinoverride.get("module", []):
30-
ifmodule.startswith("gitlab.v4.objects"):
31-
excluded_modules.add(module)
32-
33-
class_info_list= []
34-
formodule_name,module_valueininspect.getmembers(gitlab.v4.objects):
20+
class_info_set=set()
21+
for_,module_valueininspect.getmembers(gitlab.v4.objects):
3522
ifnotinspect.ismodule(module_value):
3623
# We only care about the modules
3724
continue
@@ -41,17 +28,16 @@ def pytest_generate_tests(metafunc: _pytest.python.Metafunc) -> None:
4128
continue
4229

4330
module_name=class_value.__module__
44-
# Ignore modules that mypy is ignoring
45-
ifmodule_nameinexcluded_modules:
46-
continue
47-
4831
# Ignore imported classes from gitlab.base
4932
ifmodule_name=="gitlab.base":
5033
continue
5134

52-
class_info_list.append((class_name,class_value))
35+
ifnotclass_name.endswith("Manager"):
36+
continue
37+
38+
class_info_set.add((class_name,class_value))
5339

54-
metafunc.parametrize("class_info",class_info_list)
40+
metafunc.parametrize("class_info",class_info_set)
5541

5642

5743
classTestTypeHints:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp