Skip to content

Navigation Menu

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 3ac7e78

Browse filesBrowse files
authored
Merge pull request #1767 from EliahKagan/312-gc
Replace xfail with gc.collect in TestSubmodule.test_rename
2 parents 37e234a + b66be7c commit 3ac7e78
Copy full SHA for 3ac7e78

File tree

1 file changed

+6
-12
lines changed
Filter options

1 file changed

+6
-12
lines changed

‎test/test_submodule.py

Copy file name to clipboardExpand all lines: test/test_submodule.py
+6-12Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -948,18 +948,6 @@ def test_remove_norefs(self, rwdir):
948948
sm.remove()
949949
assert not sm.exists()
950950

951-
@pytest.mark.xfail(
952-
os.name == "nt" and sys.version_info >= (3, 12),
953-
reason=(
954-
"The sm.move call fails. Submodule.move calls os.renames, which raises:\n"
955-
"PermissionError: [WinError 32] "
956-
"The process cannot access the file because it is being used by another process: "
957-
R"'C:\Users\ek\AppData\Local\Temp\test_renamekkbznwjp\parent\mymodules\myname' "
958-
R"-> 'C:\Users\ek\AppData\Local\Temp\test_renamekkbznwjp\parent\renamed\myname'"
959-
"\nThis resembles other Windows errors, but only occurs starting in Python 3.12."
960-
),
961-
raises=PermissionError,
962-
)
963951
@with_rw_directory
964952
def test_rename(self, rwdir):
965953
parent = git.Repo.init(osp.join(rwdir, "parent"))
@@ -970,6 +958,12 @@ def test_rename(self, rwdir):
970958
assert sm.rename(sm_name) is sm and sm.name == sm_name
971959
assert not sm.repo.is_dirty(index=True, working_tree=False, untracked_files=False)
972960

961+
# This is needed to work around a PermissionError on Windows, resembling others,
962+
# except new in Python 3.12. (*Maybe* this could be due to changes in CPython's
963+
# garbage collector detailed in https://github.com/python/cpython/issues/97922.)
964+
if os.name == "nt" and sys.version_info >= (3, 12):
965+
gc.collect()
966+
973967
new_path = "renamed/myname"
974968
assert sm.move(new_path).name == new_path
975969

0 commit comments

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