Skip to content

Commit d4917d0

Browse files
committed
Expand to test all three is_<platform> aliases
1 parent a07be0e commit d4917d0

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

test/deprecation/test_compat.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,29 @@ def test_cannot_access_undefined() -> None:
2525
git.compat.foo # type: ignore[attr-defined]
2626

2727

28-
def test_is_win() -> None:
28+
def test_is_platform() -> None:
29+
"""The is_<platform> aliases work, warn, and mypy accepts code accessing them."""
30+
fully_qualified_names = [
31+
"git.compat.is_win",
32+
"git.compat.is_posix",
33+
"git.compat.is_darwin",
34+
]
35+
2936
with pytest.deprecated_call() as ctx:
30-
value = git.compat.is_win
31-
(message,) = [str(entry.message) for entry in ctx] # Exactly one message.
32-
assert message.startswith(_MESSAGE_LEADER.format("git.compat.is_win"))
33-
assert value == (os.name == "nt")
37+
is_win = git.compat.is_win
38+
is_posix = git.compat.is_posix
39+
is_darwin = git.compat.is_darwin
40+
41+
messages = [str(entry.message) for entry in ctx]
42+
assert len(messages) == 3
43+
44+
for fullname, message in zip(fully_qualified_names, messages):
45+
assert message.startswith(_MESSAGE_LEADER.format(fullname))
46+
47+
# These exactly reproduce the expressions in the code under test, so they are not
48+
# good for testing that the values are correct. Instead, the purpose of this test is
49+
# to ensure that any dynamic machinery put in place in git.compat to cause warnings
50+
# to be issued does not get in the way of the intended values being accessed.
51+
assert is_win == (os.name == "nt")
52+
assert is_posix == (os.name == "posix")
53+
assert is_darwin == (sys.platform == "darwin")

0 commit comments

Comments
 (0)