コード例 #1
0
def normalize_version(version: str) -> str:
    return PEP440Version.parse(version).to_string()
コード例 #2
0
def test_pep440_parse_text_invalid_versions(text):
    with pytest.raises(InvalidVersion):
        assert PEP440Version.parse(text)
コード例 #3
0
    assert ReleaseTag(*parts).next_phase() == result


@pytest.mark.parametrize(
    "phase", list({*RELEASE_PHASES.keys(), *RELEASE_PHASES_SHORT.keys()})
)
def test_pep440_release_tag_next(phase):
    tag = ReleaseTag(phase=phase).next()
    assert tag.phase == ReleaseTag.expand(phase)
    assert tag.number == 1


@pytest.mark.parametrize(
    "text,result",
    [
        ("1", PEP440Version(release=Release.from_parts(1))),
        ("1.2.3", PEP440Version(release=Release.from_parts(1, 2, 3))),
        (
            "1.2.3-1",
            PEP440Version(
                release=Release.from_parts(1, 2, 3), post=ReleaseTag("post", 1)
            ),
        ),
        (
            "1.2.3.dev1",
            PEP440Version(
                release=Release.from_parts(1, 2, 3), dev=ReleaseTag("dev", 1)
            ),
        ),
        (
            "1.2.3-1.dev1",
コード例 #4
0
def test_pep440_parse_text(text, result):
    assert PEP440Version.parse(text) == result
コード例 #5
0
def test_pep440_parse_text(text: str, result: PEP440Version) -> None:
    assert PEP440Version.parse(text) == result