summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2022-11-10 21:14:12 +0100
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2022-11-10 21:14:12 +0100
commita197a780e1afcd605b272f2d27f73e7579b7029c (patch)
treec727d7bfea17a901c6408401543bab4c22b2efe0 /setuptools
parentac727af6acd38537cdddc6c98bc9457aa1eb991a (diff)
downloadpython-setuptools-git-a197a780e1afcd605b272f2d27f73e7579b7029c.tar.gz
Add a test for maintainers w/ international emails
The current `email.headerregistry.Address` implementation only allows RFC 5322 but the world is slowly moving towards supporting the international emails too. This patch adds a test case that is currently expected to fail but hopefully should pass once the support for RFC 6532 is implemented in the standard library. Refs: * https://datatracker.ietf.org/doc/html/rfc6532 * https://en.wikipedia.org/wiki/International_email
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/tests/config/test_apply_pyprojecttoml.py61
1 files changed, 51 insertions, 10 deletions
diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py
index 7ad327bb..3a66d494 100644
--- a/setuptools/tests/config/test_apply_pyprojecttoml.py
+++ b/setuptools/tests/config/test_apply_pyprojecttoml.py
@@ -136,6 +136,19 @@ spam-gui = "spam:main_gui"
tomatoes = "spam:main_tomatoes"
"""
+PEP621_INTERNATIONAL_EMAIL_EXAMPLE = """\
+[project]
+name = "spam"
+version = "2020.0.0"
+authors = [
+ {email = "hi@pradyunsg.me"},
+ {name = "Tzu-Ping Chung"}
+]
+maintainers = [
+ {name = "Степан Бандера", email = "криївка@оун-упа.укр"},
+]
+"""
+
PEP621_EXAMPLE_SCRIPT = """
def main_cli(): pass
def main_gui(): pass
@@ -143,9 +156,13 @@ def main_tomatoes(): pass
"""
-def _pep621_example_project(tmp_path, readme="README.rst"):
+def _pep621_example_project(
+ tmp_path,
+ readme="README.rst",
+ pyproject_text=PEP621_EXAMPLE,
+):
pyproject = tmp_path / "pyproject.toml"
- text = PEP621_EXAMPLE
+ text = pyproject_text
replacements = {'readme = "README.rst"': f'readme = "{readme}"'}
for orig, subst in replacements.items():
text = text.replace(orig, subst)
@@ -191,19 +208,43 @@ def test_no_explicit_content_type_for_missing_extension(tmp_path):
assert dist.metadata.long_description_content_type is None
-def test_utf8_maintainer_in_metadata(tmp_path): # issue-3663
- pyproject = _pep621_example_project(tmp_path, "README")
- dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
- expected = (
- 'Brett Cannon <brett@python.org>, "John X. Ãørçeč" <john@utf8.org>, '
- 'Γαμα קּ 東 <gama@utf8.org>'
+@pytest.mark.parametrize(
+ ('pyproject_text', 'expected_maintainers_meta_value'),
+ (
+ pytest.param(
+ PEP621_EXAMPLE,
+ (
+ 'Brett Cannon <brett@python.org>, "John X. Ãørçeč" <john@utf8.org>, '
+ 'Γαμα קּ 東 <gama@utf8.org>'
+ ),
+ id='non-international-emails',
+ ),
+ pytest.param(
+ PEP621_INTERNATIONAL_EMAIL_EXAMPLE,
+ 'Степан Бандера <криївка@оун-упа.укр>',
+ marks=pytest.mark.xfail(
+ reason="CPython's `email.headerregistry.Address` only supports "
+ 'RFC 5322, as of Nov 10, 2022 and latest Python 3.11.0',
+ strict=True,
+ ),
+ id='international-email',
+ ),
+ ),
+)
+def test_utf8_maintainer_in_metadata( # issue-3663
+ expected_maintainers_meta_value,
+ pyproject_text, tmp_path,
+):
+ pyproject = _pep621_example_project(
+ tmp_path, "README", pyproject_text=pyproject_text,
)
- assert dist.metadata.maintainer_email == expected
+ dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
+ assert dist.metadata.maintainer_email == expected_maintainers_meta_value
pkg_file = tmp_path / "PKG-FILE"
with open(pkg_file, "w", encoding="utf-8") as fh:
dist.metadata.write_pkg_file(fh)
content = pkg_file.read_text(encoding="utf-8")
- assert f"Maintainer-email: {expected}" in content
+ assert f"Maintainer-email: {expected_maintainers_meta_value}" in content
# TODO: After PEP 639 is accepted, we have to move the license-files