Skip to content

Replace xfail with gc.collect in TestSubmodule.test_rename #1767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replace xfail with gc.collect in TestSubmodule.test_rename
Like the xfail was, this is conditional, being done only in the
specific situation the PermissionError occurs. Besides that it does
not always run even on Windows (only in 3.12 and later), this
resembles various other conditional and non-conditional gc.collect
calls.

It had previously appeared to me that two calls to gc.collect were
required, but I am unable to reproduce that. It may have been
specific to how I was running it on my system at that time. The
need for only one call may have been brought about by changes to
the code in the mean time, but I have tested that only one call
appears required even without the changes in #1765.
  • Loading branch information
EliahKagan committed Dec 12, 2023
commit b66be7ca948307460933939bdbebc8f4ed665299
6 changes: 6 additions & 0 deletions test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,12 @@ def test_rename(self, rwdir):
assert sm.rename(sm_name) is sm and sm.name == sm_name
assert not sm.repo.is_dirty(index=True, working_tree=False, untracked_files=False)

# 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

Expand Down