Skip to content

[self tests] test_pkginfo_returns_no_metadata fails against pkginfo 1.11.0 #1116

Closed
@stanislavlevin

Description

@stanislavlevin

Is there an existing issue for this?

  • I have searched the existing issues (open and closed), and could not find an existing issue

What keywords did you use to search existing issues?

test_pkginfo_returns_no_metadata

What operating system are you using?

Linux

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

No response

What version of Python are you running?

python3 --version
Python 3.12.2

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

git clone https://github.com/pypa/twine

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

twine version 5.1.1.dev7+g6fbf880 (importlib-metadata: 7.1.0, keyring: 25.2.1,
pkginfo: 1.11.0, requests: 2.32.3, requests-toolbelt: 1.0.0, urllib3: 2.2.1)

Which package repository are you using?

https://pypi.org/

Please describe the issue that you are experiencing

test_pkginfo_returns_no_metadata test fails with:

====================================== FAILURES ======================================
___________ test_pkginfo_returns_no_metadata[unsupported Metadata-Version] ___________

read_data = b'Metadata-Version: 102.3\nName: test-package\nVersion: 1.0.0\n'
missing_fields = 'Name, Version'
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7ff1586950d0>

    @pytest.mark.parametrize(
        "read_data, missing_fields",
        [
            pytest.param(
                b"Metadata-Version: 102.3\nName: test-package\nVersion: 1.0.0\n",
                "Name, Version",
                id="unsupported Metadata-Version",
            ),
            pytest.param(
                b"Metadata-Version: 2.3\nName: UNKNOWN\nVersion: UNKNOWN\n",
                "Name, Version",
                id="missing Name and Version",
            ),
            pytest.param(
                b"Metadata-Version: 2.2\nName: UNKNOWN\nVersion: UNKNOWN\n",
                "Name, Version",
                id="missing Name and Version",
            ),
            pytest.param(
                b"Metadata-Version: 2.3\nName: UNKNOWN\nVersion: 1.0.0\n",
                "Name",
                id="missing Name",
            ),
            pytest.param(
                b"Metadata-Version: 2.2\nName: UNKNOWN\nVersion: 1.0.0\n",
                "Name",
                id="missing Name",
            ),
            pytest.param(
                b"Metadata-Version: 2.3\nName: test-package\nVersion: UNKNOWN\n",
                "Version",
                id="missing Version",
            ),
            pytest.param(
                b"Metadata-Version: 2.2\nName: test-package\nVersion: UNKNOWN\n",
                "Version",
                id="missing Version",
            ),
        ],
    )
    def test_pkginfo_returns_no_metadata(read_data, missing_fields, monkeypatch):
        """Raise an exception when pkginfo can't interpret the metadata.
    
        This could be caused by a version number or format it doesn't support yet.
        """
        monkeypatch.setattr(package_file.wheel.Wheel, "read", lambda _: read_data)
        filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"
    
>       with pytest.raises(exceptions.InvalidDistribution) as err:
E       Failed: DID NOT RAISE <class 'twine.exceptions.InvalidDistribution'>

tests/test_package.py:431: Failed

Please list the steps required to reproduce this behaviour

python3 -m tox -e py

Anything else you'd like to mention?

pkginfo 1.11.0 changed behavior if it deals with unknown metadata version:

https://bugs.launchpad.net/pkginfo/+bug/2058697
https://bazaar.launchpad.net/~tseaver/pkginfo/trunk/revision/235

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions