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

Commitd4917d0

Browse files
committed
Expand to test all three is_<platform> aliases
1 parenta07be0e commitd4917d0

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

‎test/deprecation/test_compat.py

Lines changed: 25 additions & 5 deletions
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-
deftest_is_win()->None:
28+
deftest_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
withpytest.deprecated_call()asctx:
30-
value=git.compat.is_win
31-
(message,)= [str(entry.message)forentryinctx]# Exactly one message.
32-
assertmessage.startswith(_MESSAGE_LEADER.format("git.compat.is_win"))
33-
assertvalue== (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)forentryinctx]
42+
assertlen(messages)==3
43+
44+
forfullname,messageinzip(fully_qualified_names,messages):
45+
assertmessage.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+
assertis_win== (os.name=="nt")
52+
assertis_posix== (os.name=="posix")
53+
assertis_darwin== (sys.platform=="darwin")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp