Skip to content

Commit

Permalink
In TempdirManager, use pathlib and more_itertools to more simply writ…
Browse files Browse the repository at this point in the history
…e the text.
  • Loading branch information
jaraco committed Oct 29, 2022
1 parent 01ce88b commit 85df0b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 3 additions & 8 deletions distutils/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import tempfile
import sysconfig
import itertools
import pathlib

import pytest
from more_itertools import always_iterable

from distutils.core import Distribution

Expand All @@ -29,16 +31,9 @@ def mkdtemp(self):
def write_file(self, path, content='xxx'):
"""Writes a file in the given path.
path can be a string or a sequence.
"""
if isinstance(path, (list, tuple)):
path = os.path.join(*path)
f = open(path, 'w')
try:
f.write(content)
finally:
f.close()
pathlib.Path(*always_iterable(path)).write_text(content)

def create_dist(self, pkg_name='foo', **kw):
"""Will generate a test environment.
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ deps =
path
docutils
pyfakefs
more_itertools
commands =
pytest {posargs}
setenv =
Expand Down

0 comments on commit 85df0b2

Please sign in to comment.