Skip to content

Commit 18608e4

Browse files
committed
Pick a better name for _MODULE_ALIAS_TARGETS
And add a docstring to document it, mainly to clarify that util is intentionally omitted from that constant.
1 parent 074bbc7 commit 18608e4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/deprecation/test_attributes.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_util_alias_import() -> None:
8585

8686

8787
# Split out util and have all its tests be separate, above.
88-
_MODULE_ALIAS_TARGETS = (
88+
_PRIVATE_MODULE_ALIAS_TARGETS = (
8989
git.refs.head,
9090
git.refs.log,
9191
git.refs.reference,
@@ -95,6 +95,7 @@ def test_util_alias_import() -> None:
9595
git.index.fun,
9696
git.index.typ,
9797
)
98+
"""Targets of private aliases in the git module to some modules, not including util."""
9899

99100

100101
def test_private_module_alias_access() -> None:
@@ -109,11 +110,11 @@ def test_private_module_alias_access() -> None:
109110
git.base, # type: ignore[attr-defined]
110111
git.fun, # type: ignore[attr-defined]
111112
git.typ, # type: ignore[attr-defined]
112-
) == _MODULE_ALIAS_TARGETS
113+
) == _PRIVATE_MODULE_ALIAS_TARGETS
113114

114115
# Each should have warned exactly once, and note what to use instead.
115116
messages = [str(w.message) for w in ctx]
116-
for target, message in zip(_MODULE_ALIAS_TARGETS, messages, strict=True):
117+
for target, message in zip(_PRIVATE_MODULE_ALIAS_TARGETS, messages, strict=True):
117118
assert message.endswith(f"Use {target.__name__} instead.")
118119

119120

@@ -138,13 +139,13 @@ def test_private_module_alias_import() -> None:
138139
base,
139140
fun,
140141
typ,
141-
) == _MODULE_ALIAS_TARGETS
142+
) == _PRIVATE_MODULE_ALIAS_TARGETS
142143

143144
# Each import may warn multiple times. In CPython there will be currently always be
144145
# exactly two warnings per import, possibly due to the equivalent of calling hasattr
145146
# to do a pre-check prior to retrieving the attribute for actual use. However, for
146147
# each import, all messages should be the same and should note what to use instead.
147148
messages_with_duplicates = [str(w.message) for w in ctx]
148149
messages = [message for message, _ in itertools.groupby(messages_with_duplicates)]
149-
for target, message in zip(_MODULE_ALIAS_TARGETS, messages, strict=True):
150+
for target, message in zip(_PRIVATE_MODULE_ALIAS_TARGETS, messages, strict=True):
150151
assert message.endswith(f"Use {target.__name__} instead.")

0 commit comments

Comments
 (0)