From f72e2821a3073c4e87915fe7e721512e16e4fa74 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Wed, 15 Nov 2023 12:19:10 -0500 Subject: [PATCH] Mark test_diff_submodule xfail on Windows Everything attempted in the test case method is actually working and passes, but when the tearDown method calls shutil.rmtree, it fails with "Access is denied" and raises PermissionError. The reason and exception are accordingly noted in the xfail decoration. While adding a pytest import to apply the pytest xfail mark, I also improved grouping/sorting of other imports in the test_diff module. --- test/test_diff.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/test/test_diff.py b/test/test_diff.py index 1678e737d..1d138a086 100644 --- a/test/test_diff.py +++ b/test/test_diff.py @@ -3,26 +3,17 @@ # This module is part of GitPython and is released under the # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ -import ddt +import os +import os.path as osp import shutil import tempfile -from git import ( - Repo, - GitCommandError, - Diff, - DiffIndex, - NULL_TREE, - Submodule, -) -from git.cmd import Git -from test.lib import ( - TestBase, - StringProcessAdapter, - fixture, -) -from test.lib import with_rw_directory -import os.path as osp +import ddt +import pytest + +from git import NULL_TREE, Diff, DiffIndex, GitCommandError, Repo, Submodule +from git.cmd import Git +from test.lib import StringProcessAdapter, TestBase, fixture, with_rw_directory def to_raw(input): @@ -318,6 +309,11 @@ def test_diff_with_spaces(self): self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path)) self.assertEqual(diff_index[0].b_path, "file with spaces", repr(diff_index[0].b_path)) + @pytest.mark.xfail( + os.name == "nt", + reason='"Access is denied" when tearDown calls shutil.rmtree', + raises=PermissionError, + ) def test_diff_submodule(self): """Test that diff is able to correctly diff commits that cover submodule changes""" # Init a temp git repo that will be referenced as a submodule.