Skip to content

Commit

Permalink
Add unit tests for py-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Aug 14, 2024
1 parent fa7da9f commit 0aac59e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions setuptools/tests/config/test_apply_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,33 @@ def test_default_patterns(self, tmp_path):
assert set(dist.metadata.license_files) == {*license_files, "LICENSE.txt"}


class TestPyModules:
# https://github.com/pypa/setuptools/issues/4316

def dist(self, name):
toml_config = f"""
[project]
name = "test"
version = "42.0"
[tool.setuptools]
py-modules = [{name!r}]
"""
pyproject = Path("pyproject.toml")
pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
return pyprojecttoml.apply_configuration(Distribution({}), pyproject)

@pytest.mark.parametrize("module", ["pip-run", "abc-d.λ-xyz-e"])
def test_valid_module_name(self, tmp_path, monkeypatch, module):
monkeypatch.chdir(tmp_path)
assert module in self.dist(module).py_modules

@pytest.mark.parametrize("module", ["pip run", "-pip-run", "pip-run-stubs"])
def test_invalid_module_name(self, tmp_path, monkeypatch, module):
monkeypatch.chdir(tmp_path)
with pytest.raises(ValueError, match="py-modules"):
self.dist(module).py_modules


class TestDeprecatedFields:
def test_namespace_packages(self, tmp_path):
pyproject = tmp_path / "pyproject.toml"
Expand Down

0 comments on commit 0aac59e

Please sign in to comment.