Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[self tests] test_pkginfo_returns_no_metadata fails against pkginfo 1.11.0 #1116

Open
1 task done
stanislavlevin opened this issue Jun 3, 2024 · 2 comments · May be fixed by #1123
Open
1 task done

[self tests] test_pkginfo_returns_no_metadata fails against pkginfo 1.11.0 #1116

stanislavlevin opened this issue Jun 3, 2024 · 2 comments · May be fixed by #1123
Assignees
Labels

Comments

@stanislavlevin
Copy link

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

@jaraco
Copy link
Member

jaraco commented Jun 25, 2024

As I'm looking through the links, I'm finding launchpad to be unusable. Some requests take many tens of seconds, others fail with 503 Service Unavailable. As a result, I've been unable to review the code changes or find a changelog.

I can see from the bug report that the intention was to turn the exceptions into warnings (and let clients like twine capture those warnings and handle them however).

So if I assume that twine wishes to retain the current behavior as captured by the failing test, I'll draft a change to transform the warnings.

jaraco added a commit that referenced this issue Jun 25, 2024
@jaraco
Copy link
Member

jaraco commented Jun 25, 2024

I'm no longer confident that we want twine to retain the current behavior (fail if the metadata version is not yet recognized). Since pkginfo was asked to be lenient, perhaps twine should be lenient also, allowing the warning to be emitted, but proceeding if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants