Skip to content

Commit f72e282

Browse files
committed
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.
1 parent cd9d7a9 commit f72e282

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

Diff for: test/test_diff.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,17 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6-
import ddt
6+
import os
7+
import os.path as osp
78
import shutil
89
import tempfile
9-
from git import (
10-
Repo,
11-
GitCommandError,
12-
Diff,
13-
DiffIndex,
14-
NULL_TREE,
15-
Submodule,
16-
)
17-
from git.cmd import Git
18-
from test.lib import (
19-
TestBase,
20-
StringProcessAdapter,
21-
fixture,
22-
)
23-
from test.lib import with_rw_directory
2410

25-
import os.path as osp
11+
import ddt
12+
import pytest
13+
14+
from git import NULL_TREE, Diff, DiffIndex, GitCommandError, Repo, Submodule
15+
from git.cmd import Git
16+
from test.lib import StringProcessAdapter, TestBase, fixture, with_rw_directory
2617

2718

2819
def to_raw(input):
@@ -318,6 +309,11 @@ def test_diff_with_spaces(self):
318309
self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path))
319310
self.assertEqual(diff_index[0].b_path, "file with spaces", repr(diff_index[0].b_path))
320311

312+
@pytest.mark.xfail(
313+
os.name == "nt",
314+
reason='"Access is denied" when tearDown calls shutil.rmtree',
315+
raises=PermissionError,
316+
)
321317
def test_diff_submodule(self):
322318
"""Test that diff is able to correctly diff commits that cover submodule changes"""
323319
# Init a temp git repo that will be referenced as a submodule.

0 commit comments

Comments
 (0)