From 42a3d74f529f34382b205c0ada46fb18df80c034 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Wed, 15 Nov 2023 14:14:44 -0500 Subject: [PATCH] Mark TestSubmodule.test_rename xfail on Windows The test fails when attempting to evaluate the expression: sm.move(new_path).name as part of the assertion: assert sm.move(new_path).name == new_path But it is the call to sm.move that fails, not the assertion itself. The condition is never evaluated, because the subexpression raises PermissionError. Details are in the xfail reason string. This test_submodule.TestSubmodule.test_rename method should not be confused with test_config.TestBase.test_rename, which passes on all platforms. On CI this has XPASS status on Python 3.7 and possibly some other versions. This should be investigated and, if possible, the xfail markings should be made precise. (When working on this change before a rebase, I had thought only 3.7 xpassed, and that the XPASS was only on CI, never locally. However, I am unable to reproduce that or find CI logs of it, so some of these observations may have been mistaken and/or or specific to a narrow environment.) --- test/test_submodule.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_submodule.py b/test/test_submodule.py index 5be1a1077..68dbcc491 100644 --- a/test/test_submodule.py +++ b/test/test_submodule.py @@ -949,6 +949,17 @@ def test_remove_norefs(self, rwdir): sm.remove() assert not sm.exists() + @pytest.mark.xfail( + os.name == "nt", + 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'" + ), + raises=PermissionError, + ) @with_rw_directory def test_rename(self, rwdir): parent = git.Repo.init(osp.join(rwdir, "parent"))