Skip to content

Commit

Permalink
Add test capturing missed expectation.
Browse files Browse the repository at this point in the history
Ref #304
  • Loading branch information
jaraco committed Oct 19, 2024
1 parent ce4b760 commit b1e746c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions distutils/tests/test_dir_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for distutils.dir_util."""

import os
import pathlib
import stat
import unittest.mock as mock
from distutils import dir_util, errors
Expand Down Expand Up @@ -110,3 +111,25 @@ def test_copy_tree_exception_in_listdir(self):
):
src = self.tempdirs[-1]
dir_util.copy_tree(src, None)

@pytest.mark.xfail(reason="#304")
def test_mkpath_exception_uncached(self, monkeypatch, tmp_path):
"""
Caching should not remember failed attempts.
pypa/distutils#304
"""

class FailPath(pathlib.Path):
def mkdir(self, *args, **kwargs):
raise OSError("Failed to create directory")

target = tmp_path / 'foodir'

with pytest.raises(errors.DistutilsFileError):
mkpath(FailPath(target))

assert not target.exists()

mkpath(target)
assert target.exists()

0 comments on commit b1e746c

Please sign in to comment.