Skip to content

Commit b1e746c

Browse files
committed
Add test capturing missed expectation.
Ref pypa#304
1 parent ce4b760 commit b1e746c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

distutils/tests/test_dir_util.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for distutils.dir_util."""
22

33
import os
4+
import pathlib
45
import stat
56
import unittest.mock as mock
67
from distutils import dir_util, errors
@@ -110,3 +111,25 @@ def test_copy_tree_exception_in_listdir(self):
110111
):
111112
src = self.tempdirs[-1]
112113
dir_util.copy_tree(src, None)
114+
115+
@pytest.mark.xfail(reason="#304")
116+
def test_mkpath_exception_uncached(self, monkeypatch, tmp_path):
117+
"""
118+
Caching should not remember failed attempts.
119+
120+
pypa/distutils#304
121+
"""
122+
123+
class FailPath(pathlib.Path):
124+
def mkdir(self, *args, **kwargs):
125+
raise OSError("Failed to create directory")
126+
127+
target = tmp_path / 'foodir'
128+
129+
with pytest.raises(errors.DistutilsFileError):
130+
mkpath(FailPath(target))
131+
132+
assert not target.exists()
133+
134+
mkpath(target)
135+
assert target.exists()

0 commit comments

Comments
 (0)