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

Commit8bbcb26

Browse files
committed
Call repo.close() instead of manually collecting
The code this replaces in the `commit` pytest fixture seems not tobe needed anymore, and could arguably be removed now with nofurther related changes. But whether it is needed depends onsubtle and sometimes nondeterministic factors, and may also varyacross Python versions.To be safe, this replaces it with a call to the Repo instance'sclose method, which is in effect more robust than what was beingdone before, as it calls clear_cache on the the Git object that theRepo object uses, does a gitdb/smmap collection, and on Windowscalls gc.collect both before and after that collection.This may happen immediately anyway if the Repo object is notreachable from any cycle, since the reference count should go tozero after each of the deprecation warning tests (the fixture'slifetime is that of the test case), and Repo.close is called inRepo.__del__. But this makes it happen immediately even if there isa cycle.
1 parentca385a5 commit8bbcb26

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

‎test/deprecation/test_various.py

Lines 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
importcontextlib
7-
importgc
87
importwarnings
98

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

3735

3836
@pytest.fixture

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp