fbradyirl / openwrt-luci-rpc

Other
34 stars 22 forks source link

Test failure with packaging>22 #58

Closed mweinelt closed 1 year ago

mweinelt commented 1 year ago

Description

Run the testsuite with packaging>22 and see that test_is_legacy_version fails.

What I Did

Ran pytest.

__________________ TestOpenwrtLuciRPC.test_is_legacy_version ___________________

self = <tests.test_version.TestOpenwrtLuciRPC testMethod=test_is_legacy_version>

    def test_is_legacy_version(self):
        """Test comparing versions works as expected."""

        assert is_legacy_version(version.parse("15.05")) is True
        assert is_legacy_version(version.parse("15.05.1")) is True
        assert is_legacy_version(version.parse("17.01")) is True
        assert is_legacy_version(version.parse("17.01.6")) is True

        assert is_legacy_version(version.parse("18.06")) is False
        assert is_legacy_version(version.parse("18.06.9")) is False
        assert is_legacy_version(version.parse("19.07.7")) is False

>       assert is_legacy_version(version.parse("snapshot")) is False

tests/test_version.py:33: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/igymj6b3n8gw4fqn8g1r64clv4z64p5r-python3.10-packaging-23.0/lib/python3.10/site-packages/packaging/version.py:52: in parse
    return Version(version)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'Version' object has no attribute '_version'") raised in repr()] Version object at 0x7ffff5bebc10>
version = 'snapshot'

    def __init__(self, version: str) -> None:
        """Initialize a Version object.

        :param version:
            The string representation of a version which will be parsed and normalized
            before use.
        :raises InvalidVersion:
            If the ``version`` does not conform to PEP 440 in any way then this
            exception will be raised.
        """

        # Validate the version and parse it into pieces
        match = self._regex.search(version)
        if not match:
>           raise InvalidVersion(f"Invalid version: '{version}'")
E           packaging.version.InvalidVersion: Invalid version: 'snapshot'

/nix/store/igymj6b3n8gw4fqn8g1r64clv4z64p5r-python3.10-packaging-23.0/lib/python3.10/site-packages/packaging/version.py:197: InvalidVersion
fbradyirl commented 1 year ago

Fixed in latest