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 46a739d

Browse filesBrowse files
committed
Hoist import git to module level in test module
Because it's going to be necessary to express things in terms of it in parametrization markings, in order for mypy to show the expected errors for names that are available dynamically but deliberately static type errors.
1 parent 859e38c commit 46a739d
Copy full SHA for 46a739d

File tree

1 file changed

+2
-11
lines changed
Filter options

1 file changed

+2
-11
lines changed

‎test/deprecation/test_attributes.py

Copy file name to clipboardExpand all lines: test/deprecation/test_attributes.py
+2-11Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import pytest
66

7+
import git
78

8-
def test_cannot_get_undefined() -> None:
9-
import git
109

10+
def test_cannot_get_undefined() -> None:
1111
with pytest.raises(AttributeError):
1212
git.foo
1313

@@ -19,21 +19,16 @@ def test_cannot_import_undefined() -> None:
1919

2020
def test_util_alias_access_resolves() -> None:
2121
"""These resolve for now, though they're private we do not guarantee this."""
22-
import git
23-
2422
assert git.util is git.index.util
2523

2624

2725
def test_util_alias_import_resolves() -> None:
2826
from git import util
29-
import git
3027

3128
util is git.index.util
3229

3330

3431
def test_util_alias_access_warns() -> None:
35-
import git
36-
3732
with pytest.deprecated_call() as ctx:
3833
git.util
3934

@@ -72,8 +67,6 @@ def test_util_alias_import_warns() -> None:
7267
@_parametrize_by_private_alias
7368
def test_private_module_alias_access_resolves(name: str, fullname: str) -> None:
7469
"""These resolve for now, though they're private we do not guarantee this."""
75-
import git
76-
7770
assert getattr(git, name) is importlib.import_module(fullname)
7871

7972

@@ -85,8 +78,6 @@ def test_private_module_alias_import_resolves(name: str, fullname: str) -> None:
8578

8679
@_parametrize_by_private_alias
8780
def test_private_module_alias_access_warns(name: str, fullname: str) -> None:
88-
import git
89-
9081
with pytest.deprecated_call() as ctx:
9182
getattr(git, name)
9283

0 commit comments

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