From c53b4bbfdf5ed27a91cb7d2c5c457d896275f774 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 9 Nov 2022 12:37:58 +0000 Subject: [PATCH] Ensure pyproject.toml accepts UTF-8 in maintainers --- .../tests/config/test_apply_pyprojecttoml.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index 2194197f82..7ad327bb52 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -98,7 +98,9 @@ def test_apply_pyproject_equivalent_to_setupcfg(url, monkeypatch, tmp_path): {name = "Tzu-Ping Chung"} ] maintainers = [ - {name = "Brett Cannon", email = "brett@python.org"} + {name = "Brett Cannon", email = "brett@python.org"}, + {name = "John X. Ãørçeč", email = "john@utf8.org"}, + {name = "Γαμα קּ 東", email = "gama@utf8.org"}, ] classifiers = [ "Development Status :: 4 - Beta", @@ -147,7 +149,7 @@ def _pep621_example_project(tmp_path, readme="README.rst"): replacements = {'readme = "README.rst"': f'readme = "{readme}"'} for orig, subst in replacements.items(): text = text.replace(orig, subst) - pyproject.write_text(text) + pyproject.write_text(text, encoding="utf-8") (tmp_path / readme).write_text("hello world") (tmp_path / "LICENSE.txt").write_text("--- LICENSE stub ---") @@ -189,6 +191,21 @@ 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 , "John X. Ãørçeč" , ' + 'Γαμα קּ 東 ' + ) + assert dist.metadata.maintainer_email == expected + 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 + + # TODO: After PEP 639 is accepted, we have to move the license-files # to the `project` table instead of `tool.setuptools` def test_license_and_license_files(tmp_path):