From d2529ff0767210381a99c3afe189ed66fdc139d0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 24 Sep 2022 22:51:17 -0400 Subject: [PATCH] Remove reliance on create_empty_file --- distutils/tests/py38compat.py | 2 -- distutils/tests/test_filelist.py | 35 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/distutils/tests/py38compat.py b/distutils/tests/py38compat.py index 9f6bc33f..211d3a6c 100644 --- a/distutils/tests/py38compat.py +++ b/distutils/tests/py38compat.py @@ -23,7 +23,6 @@ unlink, skip_unless_symlink, temp_dir, - create_empty_file, ) except (ModuleNotFoundError, ImportError): from test.support import ( @@ -32,7 +31,6 @@ unlink, skip_unless_symlink, temp_dir, - create_empty_file, ) diff --git a/distutils/tests/test_filelist.py b/distutils/tests/test_filelist.py index 8c1a590c..7ff9d3e8 100644 --- a/distutils/tests/test_filelist.py +++ b/distutils/tests/test_filelist.py @@ -8,10 +8,12 @@ from distutils import filelist from test.support import captured_stdout -from distutils.tests import support -from . import py38compat as os_helper import pytest +import jaraco.path + +from distutils.tests import support +from . import py38compat as os_helper MANIFEST_IN = """\ @@ -313,32 +315,25 @@ def test_basic_discovery(self, temp_cwd): '.' as the parameter, the dot should be omitted from the results. """ - os.mkdir('foo') + jaraco.path.build({'foo': {'file1.txt': ''}, 'bar': {'file2.txt': ''}}) file1 = os.path.join('foo', 'file1.txt') - os_helper.create_empty_file(file1) - os.mkdir('bar') file2 = os.path.join('bar', 'file2.txt') - os_helper.create_empty_file(file2) expected = [file2, file1] assert sorted(filelist.findall()) == expected - def test_non_local_discovery(self): + def test_non_local_discovery(self, tmp_path): """ When findall is called with another path, the full path name should be returned. """ - with os_helper.temp_dir() as temp_dir: - file1 = os.path.join(temp_dir, 'file1.txt') - os_helper.create_empty_file(file1) - expected = [file1] - assert filelist.findall(temp_dir) == expected + filename = tmp_path / 'file1.txt' + filename.write_text('') + expected = [str(filename)] + assert filelist.findall(tmp_path) == expected @os_helper.skip_unless_symlink - def test_symlink_loop(self): - with os_helper.temp_dir() as temp_dir: - link = os.path.join(temp_dir, 'link-to-parent') - content = os.path.join(temp_dir, 'somefile') - os_helper.create_empty_file(content) - os.symlink('.', link) - files = filelist.findall(temp_dir) - assert len(files) == 1 + def test_symlink_loop(self, tmp_path): + tmp_path.joinpath('link-to-parent').symlink_to('.') + tmp_path.joinpath('somefile').write_text('') + files = filelist.findall(tmp_path) + assert len(files) == 1