diff --git a/tests/test_package.py b/tests/test_package.py index 221b33c2..3c6b1091 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -383,11 +383,6 @@ def test_fips_metadata_excludes_md5_and_blake2(monkeypatch): @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", @@ -421,10 +416,7 @@ def test_fips_metadata_excludes_md5_and_blake2(monkeypatch): ], ) 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. - """ + """Raise an exception when pkginfo can't interpret the metadata.""" monkeypatch.setattr(package_file.wheel.Wheel, "read", lambda _: read_data) filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl" @@ -434,6 +426,17 @@ def test_pkginfo_returns_no_metadata(read_data, missing_fields, monkeypatch): assert ( f"Metadata is missing required fields: {missing_fields}." in err.value.args[0] ) + + +def test_pkginfo_unrecognized_version(monkeypatch): + """Raise an exception when pkginfo doesn't recognize the version.""" + data = b"Metadata-Version: 102.3\nName: test-package\nVersion: 1.0.0\n" + monkeypatch.setattr(package_file.wheel.Wheel, "read", lambda _: data) + filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl" + + with pytest.raises(exceptions.InvalidDistribution) as err: + package_file.PackageFile.from_filename(filename, comment=None) + assert "1.0, 1.1, 1.2, 2.0, 2.1, 2.2" in err.value.args[0]