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 ff4b58d

Browse filesBrowse files
committed
Extract no-deprecation-warning asserter as a context manager
+ Remove the TODO suggesting the diff not be computed from a real commit, since we're going to have the logic for that in use in forthcoming commit-specific deprecation warning tests anyway.
1 parent e3728c3 commit ff4b58d
Copy full SHA for ff4b58d

File tree

1 file changed

+11
-4
lines changed
Filter options

1 file changed

+11
-4
lines changed

‎test/deprecation/test_various.py

Copy file name to clipboardExpand all lines: test/deprecation/test_various.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Tests of assorted deprecation warnings with no extra subtleties to check."""
55

6+
import contextlib
67
import gc
78
import warnings
89

@@ -12,6 +13,15 @@
1213
from git.repo import Repo
1314

1415

16+
@contextlib.contextmanager
17+
def _assert_no_deprecation_warning():
18+
"""Context manager to assert that code does not issue any deprecation warnings."""
19+
with warnings.catch_warnings():
20+
# FIXME: Refine this to filter for deprecation warnings from GitPython.
21+
warnings.simplefilter("error", DeprecationWarning)
22+
yield
23+
24+
1525
@pytest.fixture
1626
def commit(tmp_path):
1727
"""Fixture to supply a one-commit repo's commit, enough for deprecation tests."""
@@ -26,7 +36,6 @@ def commit(tmp_path):
2636
@pytest.fixture
2737
def diff(commit):
2838
"""Fixture to supply a single-file diff."""
29-
# TODO: Consider making a fake diff rather than using a real repo and commit.
3039
(diff,) = commit.diff(NULL_TREE) # Exactly one file in the diff.
3140
yield diff
3241

@@ -39,7 +48,5 @@ def test_diff_renamed_warns(diff):
3948

4049
def test_diff_renamed_file_does_not_warn(diff):
4150
"""The preferred Diff.renamed_file property issues no deprecation warning."""
42-
with warnings.catch_warnings():
43-
# FIXME: Refine this to filter for deprecation warnings from GitPython.
44-
warnings.simplefilter("error", DeprecationWarning)
51+
with _assert_no_deprecation_warning():
4552
diff.renamed_file

0 commit comments

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