def test_pypy_versions(): assert pypy_versions({ Version.from_string(v) for v in ['2.7', '3.4', '3.7-dev', '3.8', 'nightly', 'PyPy3', 'Jython'] }) == {Version.from_string(v) for v in ['PyPy3']}
def test_version_from_string() -> None: assert Version.from_string('3') == Version(major=3) assert Version.from_string('3.0') == Version(major=3, minor=0) assert Version.from_string('3.6') == Version(major=3, minor=6) assert Version.from_string('3.10-dev') == Version('', 3, 10, '-dev') assert Version.from_string('PyPy') == Version('PyPy') assert Version.from_string('PyPy3') == Version('PyPy', 3) assert Version.from_string('PyPy-dev') == Version('PyPy', suffix='-dev') assert Version.from_string('PyPy3-dev') == Version('PyPy', 3, -1, '-dev') assert Version.from_string('3') != Version.from_string('3.0')
def test_version_sorting(): assert sorted( Version.from_string(v) for v in [ '2.7', '3.1', '3.6', '3.10', '3.10-dev', 'PyPy', 'PyPy3', 'nightly', ]) == [ Version.from_string(v) for v in [ '2.7', '3.1', '3.6', '3.10', '3.10-dev', 'PyPy', 'PyPy3', 'nightly', ] ]
def v(versions: List[str]) -> List[Version]: return [Version.from_string(v) for v in versions]
def test_parse_gh_ver(s, expected): assert parse_gh_ver(s) == Version.from_string(expected)
def test_tox_env_to_py_version(s, expected): expected = expected and Version.from_string(expected) assert tox_env_to_py_version(s) == expected
def test_version_str_roundtrips(v): assert str(Version.from_string(v)) == v
def test_expand_pypy(versions, expected): assert expand_pypy([Version.from_string(v) for v in versions ]) == [Version.from_string(v) for v in expected]
def test_travis_normalize_py_version(s, expected): assert travis_normalize_py_version(s) == Version.from_string(expected)
def test_appveyor_normalize_py_version(s, expected): expected = expected and Version.from_string(expected) assert appveyor_normalize_py_version(s) == expected