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 8bbcb26

Browse filesBrowse files
committed
Call repo.close() instead of manually collecting
The code this replaces in the `commit` pytest fixture seems not to be needed anymore, and could arguably be removed now with no further related changes. But whether it is needed depends on subtle and sometimes nondeterministic factors, and may also vary across Python versions. To be safe, this replaces it with a call to the Repo instance's close method, which is in effect more robust than what was being done before, as it calls clear_cache on the the Git object that the Repo object uses, does a gitdb/smmap collection, and on Windows calls gc.collect both before and after that collection. This may happen immediately anyway if the Repo object is not reachable from any cycle, since the reference count should go to zero after each of the deprecation warning tests (the fixture's lifetime is that of the test case), and Repo.close is called in Repo.__del__. But this makes it happen immediately even if there is a cycle.
1 parent ca385a5 commit 8bbcb26
Copy full SHA for 8bbcb26

File tree

1 file changed

+1
-3
lines changed
Filter options

1 file changed

+1
-3
lines changed

‎test/deprecation/test_various.py

Copy file name to clipboardExpand all lines: test/deprecation/test_various.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""Tests of assorted deprecation warnings with no extra subtleties to check."""
55

66
import contextlib
7-
import gc
87
import warnings
98

109
import pytest
@@ -31,8 +30,7 @@ def commit(tmp_path):
3130
repo = Repo.init(tmp_path)
3231
repo.index.add(["a.txt"])
3332
yield repo.index.commit("Initial commit")
34-
del repo
35-
gc.collect()
33+
repo.close()
3634

3735

3836
@pytest.fixture

0 commit comments

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