File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1
1
"""Tests for distutils.dir_util."""
2
2
3
3
import os
4
+ import pathlib
4
5
import stat
5
6
import unittest .mock as mock
6
7
from distutils import dir_util , errors
@@ -110,3 +111,25 @@ def test_copy_tree_exception_in_listdir(self):
110
111
):
111
112
src = self .tempdirs [- 1 ]
112
113
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 ()
You can’t perform that action at this time.
0 commit comments