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 e3728c3

Browse filesBrowse files
committed
Decompose new fixture logic better
This will be even more helpful when testing a deprecated member of the Commit class (not yet done).
1 parent bc111b7 commit e3728c3
Copy full SHA for e3728c3

File tree

1 file changed

+15
-10
lines changed
Filter options

1 file changed

+15
-10
lines changed

‎test/deprecation/test_various.py

Copy file name to clipboardExpand all lines: test/deprecation/test_various.py
+15-10Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,33 @@
1313

1414

1515
@pytest.fixture
16-
def single_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+
def commit(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+
yield repo.index.commit("Initial commit")
22+
del repo
23+
gc.collect()
24+
25+
26+
@pytest.fixture
27+
def diff(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
yield diff
25-
del repo, commit, diff
26-
gc.collect()
2732

2833

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

3439

35-
def test_diff_renamed_file_does_not_warn(single_diff):
40+
def test_diff_renamed_file_does_not_warn(diff):
3641
"""The preferred Diff.renamed_file property issues no deprecation warning."""
3742
with warnings.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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.