From 85df0b24d56d6629289db72539ccd070a9560a3a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 29 Oct 2022 17:06:33 -0400 Subject: [PATCH] In TempdirManager, use pathlib and more_itertools to more simply write the text. --- distutils/tests/support.py | 11 +++-------- tox.ini | 1 + 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/distutils/tests/support.py b/distutils/tests/support.py index 86431539..fd4b11bf 100644 --- a/distutils/tests/support.py +++ b/distutils/tests/support.py @@ -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 @@ -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. diff --git a/tox.ini b/tox.ini index d8d46d3f..c4200483 100644 --- a/tox.ini +++ b/tox.ini @@ -22,6 +22,7 @@ deps = path docutils pyfakefs + more_itertools commands = pytest {posargs} setenv =