Replace xfail with gc.collect in TestSubmodule.test_rename by EliahKagan · Pull Request #1767 · gitpython-developers/GitPython
@pytest.mark.xfail( os.name == "nt" and sys.version_info >= (3, 12), reason=( "The sm.move call fails. Submodule.move calls os.renames, which raises:\n" "PermissionError: [WinError 32] " "The process cannot access the file because it is being used by another process: " R"'C:\Users\ek\AppData\Local\Temp\test_renamekkbznwjp\parent\mymodules\myname' " R"-> 'C:\Users\ek\AppData\Local\Temp\test_renamekkbznwjp\parent\renamed\myname'" "\nThis resembles other Windows errors, but only occurs starting in Python 3.12." ), raises=PermissionError, ) @with_rw_directory def test_rename(self, rwdir): parent = git.Repo.init(osp.join(rwdir, "parent"))
# This is needed to work around a PermissionError on Windows, resembling others, # except new in Python 3.12. (*Maybe* this could be due to changes in CPython's # garbage collector detailed in https://github.com/python/cpython/issues/97922.) if os.name == "nt" and sys.version_info >= (3, 12): gc.collect()
new_path = "renamed/myname" assert sm.move(new_path).name == new_path