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

Commita07be0e

Browse files
committed
Start on test_compat
And rename test_attributes to test_toplevel accordingly.
1 parent5b1fa58 commita07be0e

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

‎test/deprecation/test_compat.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Tests for dynamic and static errors and warnings in GitPython's git.compat module.
2+
3+
These tests verify that the is_<platform> aliases are available, and are even listed in
4+
the output of dir(), but issue warnings, and that bogus (misspelled or unrecognized)
5+
attribute access is still an error both at runtime and with mypy. This is similar to
6+
some of the tests in test_toplevel, but the situation being tested here is simpler
7+
because it does not involve unintuitive module aliasing or import behavior. So this only
8+
tests attribute access, not "from" imports (whose behavior can be intuitively inferred).
9+
"""
10+
11+
importos
12+
importsys
13+
14+
importpytest
15+
16+
importgit.compat
17+
18+
19+
_MESSAGE_LEADER="{} and other is_<platform> aliases are deprecated."
20+
21+
22+
deftest_cannot_access_undefined()->None:
23+
"""Accessing a bogus attribute in git.compat remains a dynamic and static error."""
24+
withpytest.raises(AttributeError):
25+
git.compat.foo# type: ignore[attr-defined]
26+
27+
28+
deftest_is_win()->None:
29+
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")

‎test/deprecation/test_attributes.pyrenamed to‎test/deprecation/test_toplevel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests for dynamic and staticattributeerrors in GitPython's top-level git module.
1+
"""Tests for dynamic and static errors and warnings in GitPython's top-level git module.
22
33
Provided mypy has ``warn_unused_ignores = true`` set, running mypy on these test cases
44
checks static typing of the code under test. This is the reason for the many separate
@@ -31,13 +31,13 @@
3131

3232

3333
deftest_cannot_access_undefined()->None:
34-
"""Accessing a bogus attribute in git remainsbotha dynamic and static error."""
34+
"""Accessing a bogus attribute in git remains a dynamic and static error."""
3535
withpytest.raises(AttributeError):
3636
git.foo# type: ignore[attr-defined]
3737

3838

3939
deftest_cannot_import_undefined()->None:
40-
"""Importing a bogus attribute from git remainsbotha dynamic and static error."""
40+
"""Importing a bogus attribute from git remains a dynamic and static error."""
4141
withpytest.raises(ImportError):
4242
fromgitimportfoo# type: ignore[attr-defined] # noqa: F401
4343

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp