Skip to content

Commit 2af90ac

Browse files
committed
Update tests in setuptools/dist not to rely on Setuptools having a license file.
1 parent 63588b6 commit 2af90ac

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

setuptools/dist.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,13 @@ def _expand_patterns(
471471
cls, patterns: list[str], enforce_match: bool = True
472472
) -> Iterator[str]:
473473
"""
474-
>>> list(Distribution._expand_patterns(['LICENSE']))
475-
['LICENSE']
474+
>>> getfixture('sample_project_cwd')
475+
>>> list(Distribution._expand_patterns(['LICENSE.txt']))
476+
['LICENSE.txt']
476477
>>> list(Distribution._expand_patterns(['pyproject.toml', 'LIC*']))
477-
['pyproject.toml', 'LICENSE']
478-
>>> list(Distribution._expand_patterns(['setuptools/**/pyprojecttoml.py']))
479-
['setuptools/config/pyprojecttoml.py']
478+
['pyproject.toml', 'LICENSE.txt']
479+
>>> list(Distribution._expand_patterns(['src/**/*.dat']))
480+
['src/sample/package_data.dat']
480481
"""
481482
return (
482483
path.replace(os.sep, "/")
@@ -488,8 +489,9 @@ def _expand_patterns(
488489
@staticmethod
489490
def _find_pattern(pattern: str, enforce_match: bool = True) -> list[str]:
490491
r"""
491-
>>> Distribution._find_pattern("LICENSE")
492-
['LICENSE']
492+
>>> getfixture('sample_project_cwd')
493+
>>> Distribution._find_pattern("LICENSE.txt")
494+
['LICENSE.txt']
493495
>>> Distribution._find_pattern("/LICENSE.MIT")
494496
Traceback (most recent call last):
495497
...

setuptools/tests/fixtures.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ def sample_project(tmp_path):
6060
return tmp_path / 'sampleproject'
6161

6262

63+
@pytest.fixture
64+
def sample_project_cwd(sample_project):
65+
with contextlib.chdir(sample_project):
66+
yield
67+
68+
6369
# sdist and wheel artifacts should be stable across a round of tests
6470
# so we can build them once per session and use the files as "readonly"
6571

0 commit comments

Comments
 (0)