Skip to content

Commit bc1aa6f

Browse files
committed
Restore expectation that mkpath returns a list of the items it created.
Closes pypa#305
1 parent 378984e commit bc1aa6f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

distutils/dir_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def mkpath(name: pathlib.Path, mode=0o777, verbose=True, dry_run=False):
5858
log.info("creating %s", name)
5959

6060
ancestry = itertools.chain((name,), name.parents)
61-
missing = (path for path in ancestry if not path.is_dir())
61+
missing = list(path for path in ancestry if not path.is_dir())
6262

6363
try:
6464
dry_run or name.mkdir(mode=mode, parents=True, exist_ok=True)

distutils/tests/test_dir_util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ def test_mkpath_with_custom_mode(self):
5252
mkpath(self.target2, 0o555)
5353
assert stat.S_IMODE(os.stat(self.target2).st_mode) == 0o555 & ~umask
5454

55+
def test_mkpath_returns_as_described(self, tmp_path):
56+
"""
57+
Per the docstring, mkpath should return the list of directories created.
58+
59+
pypa/distutils#305 revealed that the return value is always the empty
60+
string and no one complained. Consider removing this expectation.
61+
"""
62+
target = tmp_path / 'foodir'
63+
res = mkpath(target)
64+
assert res == [str(target)]
65+
5566
def test_create_tree_verbosity(self, caplog):
5667
create_tree(self.root_target, ['one', 'two', 'three'], verbose=False)
5768
assert caplog.messages == []

0 commit comments

Comments
 (0)