summaryrefslogtreecommitdiff
path: root/setuptools/tests/config
diff options
context:
space:
mode:
authorwim glenn <hey@wimglenn.com>2022-04-29 22:34:27 -0500
committerwim glenn <hey@wimglenn.com>2022-04-29 22:34:27 -0500
commit1cfa27c05bd6753c7a7c5fa4cb498c85ce088392 (patch)
treebc7248e3ffa0c8a622f55959065e71dd3076ee36 /setuptools/tests/config
parentddb8844eac49e0bf3b4f20067b425ffeac1531a2 (diff)
downloadpython-setuptools-git-1cfa27c05bd6753c7a7c5fa4cb498c85ce088392.tar.gz
do not backfill Project-URL: homepage into Home-page: field (causes duplicates on PyPI). prevent "UNKNOWN" vals from appearing in summary, license, platform. prevent an extra newline getting added in long description
Diffstat (limited to 'setuptools/tests/config')
-rw-r--r--setuptools/tests/config/test_apply_pyprojecttoml.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py
index 045d7f40..4f541697 100644
--- a/setuptools/tests/config/test_apply_pyprojecttoml.py
+++ b/setuptools/tests/config/test_apply_pyprojecttoml.py
@@ -298,19 +298,26 @@ class TestMeta:
def core_metadata(dist) -> str:
with io.StringIO() as buffer:
dist.metadata.write_pkg_file(buffer)
- value = "\n".join(buffer.getvalue().strip().splitlines())
+ pkg_file_txt = buffer.getvalue()
+ skip_prefixes = ()
+ skip_lines = set()
# ---- DIFF NORMALISATION ----
# PEP 621 is very particular about author/maintainer metadata conversion, so skip
- value = re.sub(r"^(Author|Maintainer)(-email)?:.*$", "", value, flags=re.M)
+ skip_prefixes += ("Author:", "Author-email:", "Maintainer:", "Maintainer-email:")
# May be redundant with Home-page
- value = re.sub(r"^Project-URL: Homepage,.*$", "", value, flags=re.M)
+ skip_prefixes += ("Project-URL: Homepage,", "Home-page:")
# May be missing in original (relying on default) but backfilled in the TOML
- value = re.sub(r"^Description-Content-Type:.*$", "", value, flags=re.M)
+ skip_prefixes += ("Description-Content-Type:",)
# ini2toml can automatically convert `tests_require` to `testing` extra
- value = value.replace("Provides-Extra: testing\n", "")
+ skip_lines.add("Provides-Extra: testing")
# Remove empty lines
- value = re.sub(r"^\s*$", "", value, flags=re.M)
- value = re.sub(r"^\n", "", value, flags=re.M)
+ skip_lines.add("")
- return value
+ result = []
+ for line in pkg_file_txt.splitlines():
+ if line.startswith(skip_prefixes) or line in skip_lines:
+ continue
+ result.append(line + "\n")
+
+ return "".join(result)