From cd9e29f435761259169098cfad88a175a9c29605 Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Sat, 26 Mar 2022 06:19:17 -0400 Subject: [PATCH] Make missing long_description check more flexible. A missing `long_description` results in `UNKNOWN` being written to PKG-INFO, but at some point, the number of trailing newlines changed. See https://github.com/pypa/readme_renderer/pull/231#discussion_r830531638 --- tests/test_check.py | 5 +++-- twine/commands/check.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_check.py b/tests/test_check.py index 66809ccf..cd722adc 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -107,10 +107,11 @@ def test_check_passing_distribution_with_none_renderer( assert capsys.readouterr().out == "Checking dist/dist.tar.gz: PASSED\n" -def test_check_no_description(monkeypatch, capsys, caplog): +@pytest.mark.parametrize("description", [None, "UNKNOWN\n\n", "UNKNOWN\n\n\n"]) +def test_check_no_description(description, monkeypatch, capsys, caplog): package = pretend.stub( metadata_dictionary=lambda: { - "description": None, + "description": description, "description_content_type": None, } ) diff --git a/twine/commands/check.py b/twine/commands/check.py index d4f0f25f..faefeb69 100644 --- a/twine/commands/check.py +++ b/twine/commands/check.py @@ -93,7 +93,7 @@ def _check_file( content_type, params = cgi.parse_header(description_content_type) renderer = _RENDERERS.get(content_type, _RENDERERS[None]) - if description in {None, "UNKNOWN\n\n\n"}: + if description is None or description.rstrip("\n") == "UNKNOWN": warnings.append("`long_description` missing.") elif renderer: rendering_result = renderer.render(