Skip to content

Commit

Permalink
Remove reliance on create_empty_file
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 25, 2022
1 parent 3980ab7 commit d2529ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
2 changes: 0 additions & 2 deletions distutils/tests/py38compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
unlink,
skip_unless_symlink,
temp_dir,
create_empty_file,
)
except (ModuleNotFoundError, ImportError):
from test.support import (
Expand All @@ -32,7 +31,6 @@
unlink,
skip_unless_symlink,
temp_dir,
create_empty_file,
)


Expand Down
35 changes: 15 additions & 20 deletions distutils/tests/test_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """\
Expand Down Expand Up @@ -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

0 comments on commit d2529ff

Please sign in to comment.