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

Commita0ef537

Browse files
committed
Start on test_types
1 parent96089c8 commita0ef537

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎test/deprecation/test_types.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Tests for dynamic and static characteristics of git.types module attributes."""
2+
3+
importsys
4+
5+
ifsys.version_info>= (3,8):
6+
fromtypingimportLiteral
7+
else:
8+
fromtyping_extensionsimportLiteral
9+
10+
importpytest
11+
12+
importgit.types
13+
14+
15+
deftest_cannot_access_undefined()->None:
16+
"""Accessing a bogus attribute in git.types remains a dynamic and static error."""
17+
withpytest.raises(AttributeError):
18+
git.types.foo# type: ignore[attr-defined]
19+
20+
21+
deftest_lit_commit_ish()->None:
22+
""" """
23+
# It would be fine to test attribute access rather than a "from" import. But a
24+
# "from" import is more likely to appear in actual usage, so it is used here.
25+
withpytest.deprecated_call()asctx:
26+
fromgit.typesimportLit_commit_ish
27+
28+
# As noted in test_toplevel.test_util_alias_import, there may be multiple warnings,
29+
# but all with the same message.
30+
(message,)= {str(entry.message)forentryinctx}
31+
assert"Lit_commit_ish is deprecated."inmessage
32+
assert'Literal["commit", "tag", "blob", "tree"]'inmessage,"Has old definition."
33+
assert'Literal["commit", "tag"]'inmessage,"Has new definition."
34+
assert"GitObjectTypeString"inmessage,"Has new type name for old definition."
35+
36+
_:Lit_commit_ish="commit"# type: ignore[valid-type]
37+
38+
# It should be as documented (even though deliberately unusable in static checks).
39+
assertLit_commit_ish==Literal["commit","tag"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp