pypa / twine

Utilities for interacting with PyPI
https://twine.readthedocs.io/
Apache License 2.0
1.61k stars 308 forks source link

test_pkginfo_returns_no_metadata[unsupported Metadata-Version] fails #1071

Closed mcepl closed 7 months ago

mcepl commented 7 months ago

Is there an existing issue for this?

What keywords did you use to search existing issues?

unsupported Metadata-Version test_pkginfo_returns_no_metadata

What operating system are you using?

Linux

If you selected 'Other', describe your Operating System here

openSUSE/Tumbleweed (packaging for it)

What version of Python are you running?

Multiple versions, but this was done with 3.9.18

How did you install twine? Did you use your operating system's package manager or pip or something else?

Packaging it, tarball from PyPI

What version of twine do you have installed (include the complete output)

twine version 5.0.0 (importlib-metadata: 7.0.2, keyring: 24.3.1, pkginfo: 1.10.0, requests: 2.31.0, requests-toolbelt: 1.0.0, urllib3: 2.1.0)

Which package repository are you using?

https://files.pythonhosted.org/packages/source/t/twine/twine-%{version}.tar.gz

Please describe the issue that you are experiencing

When running the test suite test test_pkginfo_returns_no_metadata[unsupported Metadata-Version] fails:

[   10s] =================================== FAILURES ===================================
[   10s] ________ test_pkginfo_returns_no_metadata[unsupported Metadata-Version] ________
[   10s] 
[   10s] read_data = b'Metadata-Version: 2.3\nName: test-package\nVersion: 1.0.0\n'
[   10s] missing_fields = 'Name, Version'
[   10s] monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f497ca29d30>
[   10s] 
[   10s]     @pytest.mark.parametrize(
[   10s]         "read_data, missing_fields",
[   10s]         [
[   10s]             pytest.param(
[   10s]                 b"Metadata-Version: 2.3\nName: test-package\nVersion: 1.0.0\n",
[   10s]                 "Name, Version",
[   10s]                 id="unsupported Metadata-Version",
[   10s]             ),
[   10s]             pytest.param(
[   10s]                 b"Metadata-Version: 2.2\nName: UNKNOWN\nVersion: UNKNOWN\n",
[   10s]                 "Name, Version",
[   10s]                 id="missing Name and Version",
[   10s]             ),
[   10s]             pytest.param(
[   10s]                 b"Metadata-Version: 2.2\nName: UNKNOWN\nVersion: 1.0.0\n",
[   10s]                 "Name",
[   10s]                 id="missing Name",
[   10s]             ),
[   10s]             pytest.param(
[   10s]                 b"Metadata-Version: 2.2\nName: test-package\nVersion: UNKNOWN\n",
[   10s]                 "Version",
[   10s]                 id="missing Version",
[   10s]             ),
[   10s]         ],
[   10s]     )
[   10s]     def test_pkginfo_returns_no_metadata(read_data, missing_fields, monkeypatch):
[   10s]         """Raise an exception when pkginfo can't interpret the metadata.
[   10s]     
[   10s]         This could be caused by a version number or format it doesn't support yet.
[   10s]         """
[   10s]         monkeypatch.setattr(package_file.wheel.Wheel, "read", lambda _: read_data)
[   10s]         filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"
[   10s]     
[   10s]         with pytest.raises(exceptions.InvalidDistribution) as err:
[   10s] >           package_file.PackageFile.from_filename(filename, comment=None)
[   10s] E           Failed: DID NOT RAISE <class 'twine.exceptions.InvalidDistribution'>
[   10s] 
[   10s] tests/test_package.py:373: Failed
[   10s] =========================== short test summary info ============================
[   10s] FAILED tests/test_package.py::test_pkginfo_returns_no_metadata[unsupported Metadata-Version]
[   10s] ================= 1 failed, 183 passed, 3 deselected in 2.28s ==================

Complete build log

When I comment this one testcase data from the test parameters, the rest will pass.

Please list the steps required to reproduce this behaviour

See above

Anything else you'd like to mention?

No response

sigmavirus24 commented 7 months ago

Closed by #1077