Skip to content

Commit 85df0b2

Browse files
committed
In TempdirManager, use pathlib and more_itertools to more simply write the text.
1 parent 01ce88b commit 85df0b2

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

distutils/tests/support.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import tempfile
66
import sysconfig
77
import itertools
8+
import pathlib
89

910
import pytest
11+
from more_itertools import always_iterable
1012

1113
from distutils.core import Distribution
1214

@@ -29,16 +31,9 @@ def mkdtemp(self):
2931
def write_file(self, path, content='xxx'):
3032
"""Writes a file in the given path.
3133
32-
3334
path can be a string or a sequence.
3435
"""
35-
if isinstance(path, (list, tuple)):
36-
path = os.path.join(*path)
37-
f = open(path, 'w')
38-
try:
39-
f.write(content)
40-
finally:
41-
f.close()
36+
pathlib.Path(*always_iterable(path)).write_text(content)
4237

4338
def create_dist(self, pkg_name='foo', **kw):
4439
"""Will generate a test environment.

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ deps =
2222
path
2323
docutils
2424
pyfakefs
25+
more_itertools
2526
commands =
2627
pytest {posargs}
2728
setenv =

0 commit comments

Comments
 (0)