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

Commit983fda7

Browse files
committed
Move mark-sharing tests into a class
1 parentd00c843 commit983fda7

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

‎test/deprecation/test_attributes.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def test_util_alias_import_warns() -> None:
4949
assert"should not be relied on"inmessage
5050

5151

52-
deftest_private_module_aliases()->None:
53-
"""These existdynamically (for now) but mypy treats them as absent (intentionally).
52+
deftest_private_module_aliases_exist_dynamically()->None:
53+
"""These existat runtime (for now) but mypy treats them as absent (intentionally).
5454
5555
This code verifies the effect of static type checking when analyzed by mypy, if mypy
5656
is configured with ``warn_unused_ignores = true``.
@@ -67,7 +67,7 @@ def test_private_module_aliases() -> None:
6767
git.typ# type: ignore[attr-defined]
6868

6969

70-
_parametrize_by_private_alias=pytest.mark.parametrize(
70+
@pytest.mark.parametrize(
7171
"name, fullname",
7272
[
7373
("head","git.refs.head"),
@@ -80,32 +80,26 @@ def test_private_module_aliases() -> None:
8080
("typ","git.index.typ"),
8181
],
8282
)
83+
classTestPrivateModuleAliases:
84+
"""Tests of the private module aliases' shared specific runtime behaviors."""
8385

86+
deftest_private_module_alias_access_resolves(self,name:str,fullname:str)->None:
87+
"""These resolve for now, though they're private we do not guarantee this."""
88+
assertgetattr(git,name)isimportlib.import_module(fullname)
8489

85-
@_parametrize_by_private_alias
86-
deftest_private_module_alias_access_resolves(name:str,fullname:str)->None:
87-
"""These resolve for now, though they're private we do not guarantee this."""
88-
assertgetattr(git,name)isimportlib.import_module(fullname)
89-
90-
91-
@_parametrize_by_private_alias
92-
deftest_private_module_alias_import_resolves(name:str,fullname:str)->None:
93-
exec(f"from git import{name}")
94-
assertlocals()[name]isimportlib.import_module(fullname)
95-
96-
97-
@_parametrize_by_private_alias
98-
deftest_private_module_alias_access_warns(name:str,fullname:str)->None:
99-
withpytest.deprecated_call()asctx:
100-
getattr(git,name)
90+
deftest_private_module_alias_import_resolves(self,name:str,fullname:str)->None:
91+
exec(f"from git import{name}")
92+
assertlocals()[name]isimportlib.import_module(fullname)
10193

102-
assertlen(ctx)==1
103-
assertctx[0].message.args[0].endswith(f"Use{fullname} instead.")
94+
deftest_private_module_alias_access_warns(self,name:str,fullname:str)->None:
95+
withpytest.deprecated_call()asctx:
96+
getattr(git,name)
10497

98+
assertlen(ctx)==1
99+
assertctx[0].message.args[0].endswith(f"Use{fullname} instead.")
105100

106-
@_parametrize_by_private_alias
107-
deftest_private_module_alias_import_warns(name:str,fullname:str)->None:
108-
withpytest.deprecated_call()asctx:
109-
exec(f"from git import{name}")
101+
deftest_private_module_alias_import_warns(self,name:str,fullname:str)->None:
102+
withpytest.deprecated_call()asctx:
103+
exec(f"from git import{name}")
110104

111-
assertctx[0].message.args[0].endswith(f"Use{fullname} instead.")
105+
assertctx[0].message.args[0].endswith(f"Use{fullname} instead.")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp