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

Commitff4b58d

Browse 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 parente3728c3 commitff4b58d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎test/deprecation/test_various.py

Lines 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+
importcontextlib
67
importgc
78
importwarnings
89

@@ -12,6 +13,15 @@
1213
fromgit.repoimportRepo
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+
withwarnings.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
defcommit(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
defdiff(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
yielddiff
3241

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

4049
deftest_diff_renamed_file_does_not_warn(diff):
4150
"""The preferred Diff.renamed_file property issues no deprecation warning."""
42-
withwarnings.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)

[8]ページ先頭

©2009-2025 Movatter.jp