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 11"""Tests for distutils.dir_util."""
22
33import os
4+ import pathlib
45import stat
56import unittest .mock as mock
67from 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 ()
You can’t perform that action at this time.
0 commit comments