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

Appearance settings

Commit a07be0e

Browse filesBrowse files
committed
Start on test_compat
And rename test_attributes to test_toplevel accordingly.
1 parent 5b1fa58 commit a07be0e
Copy full SHA for a07be0e

File tree

Expand file treeCollapse file tree

2 files changed

+36
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+36
-3
lines changed

‎test/deprecation/test_compat.py

Copy file name to clipboard
+33Lines 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+
import os
12+
import sys
13+
14+
import pytest
15+
16+
import git.compat
17+
18+
19+
_MESSAGE_LEADER = "{} and other is_<platform> aliases are deprecated."
20+
21+
22+
def test_cannot_access_undefined() -> None:
23+
"""Accessing a bogus attribute in git.compat remains a dynamic and static error."""
24+
with pytest.raises(AttributeError):
25+
git.compat.foo # type: ignore[attr-defined]
26+
27+
28+
def test_is_win() -> None:
29+
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")

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

Copy file name to clipboardExpand all lines: test/deprecation/test_toplevel.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests for dynamic and static attribute errors 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
def test_cannot_access_undefined() -> None:
34-
"""Accessing a bogus attribute in git remains both a dynamic and static error."""
34+
"""Accessing a bogus attribute in git remains a dynamic and static error."""
3535
with pytest.raises(AttributeError):
3636
git.foo # type: ignore[attr-defined]
3737

3838

3939
def test_cannot_import_undefined() -> None:
40-
"""Importing a bogus attribute from git remains both a dynamic and static error."""
40+
"""Importing a bogus attribute from git remains a dynamic and static error."""
4141
with pytest.raises(ImportError):
4242
from git import foo # type: ignore[attr-defined] # noqa: F401
4343

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.