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

Commite3728c3

Browse files
committed
Decompose new fixture logic better
This will be even more helpful when testing a deprecated member ofthe Commit class (not yet done).
1 parentbc111b7 commite3728c3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

‎test/deprecation/test_various.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,33 @@
1313

1414

1515
@pytest.fixture
16-
defsingle_diff(tmp_path):
17-
"""Fixture to supply a single-file diff."""
18-
# TODO: Consider making a fake diff rather than using a real repo and commit.
16+
defcommit(tmp_path):
17+
"""Fixture to supply a one-commit repo's commit, enough for deprecation tests."""
1918
(tmp_path/"a.txt").write_text("hello\n",encoding="utf-8")
2019
repo=Repo.init(tmp_path)
2120
repo.index.add(["a.txt"])
22-
commit=repo.index.commit("Initial commit")
21+
yieldrepo.index.commit("Initial commit")
22+
delrepo
23+
gc.collect()
24+
25+
26+
@pytest.fixture
27+
defdiff(commit):
28+
"""Fixture to supply a single-file diff."""
29+
# TODO: Consider making a fake diff rather than using a real repo and commit.
2330
(diff,)=commit.diff(NULL_TREE)# Exactly one file in the diff.
2431
yielddiff
25-
delrepo,commit,diff
26-
gc.collect()
2732

2833

29-
deftest_diff_renamed_warns(single_diff):
34+
deftest_diff_renamed_warns(diff):
3035
"""The deprecated Diff.renamed property issues a deprecation warning."""
3136
withpytest.deprecated_call():
32-
single_diff.renamed
37+
diff.renamed
3338

3439

35-
deftest_diff_renamed_file_does_not_warn(single_diff):
40+
deftest_diff_renamed_file_does_not_warn(diff):
3641
"""The preferred Diff.renamed_file property issues no deprecation warning."""
3742
withwarnings.catch_warnings():
3843
# FIXME: Refine this to filter for deprecation warnings from GitPython.
3944
warnings.simplefilter("error",DeprecationWarning)
40-
single_diff.renamed_file
45+
diff.renamed_file

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp