How to use the dunamai.serialize_pvp function in dunamai

To help you get started, we’ve selected a few dunamai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_pvp():
    assert serialize_pvp("1") == "1"
    assert serialize_pvp("1.2") == "1.2"
    assert serialize_pvp("1.2.3") == "1.2.3"
    assert serialize_pvp("1.2.3.4") == "1.2.3.4"
    assert serialize_pvp("1.2.3", metadata=["foo"]) == "1.2.3-foo"
    assert serialize_pvp("1.2.3", metadata=["foo", "bar"]) == "1.2.3-foo-bar"
    assert serialize_pvp("1.2.3", metadata=[4]) == "1.2.3-4"

    with pytest.raises(ValueError):
        serialize_pvp("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_pvp():
    assert serialize_pvp("1") == "1"
    assert serialize_pvp("1.2") == "1.2"
    assert serialize_pvp("1.2.3") == "1.2.3"
    assert serialize_pvp("1.2.3.4") == "1.2.3.4"
    assert serialize_pvp("1.2.3", metadata=["foo"]) == "1.2.3-foo"
    assert serialize_pvp("1.2.3", metadata=["foo", "bar"]) == "1.2.3-foo-bar"
    assert serialize_pvp("1.2.3", metadata=[4]) == "1.2.3-4"

    with pytest.raises(ValueError):
        serialize_pvp("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_pvp():
    assert serialize_pvp("1") == "1"
    assert serialize_pvp("1.2") == "1.2"
    assert serialize_pvp("1.2.3") == "1.2.3"
    assert serialize_pvp("1.2.3.4") == "1.2.3.4"
    assert serialize_pvp("1.2.3", metadata=["foo"]) == "1.2.3-foo"
    assert serialize_pvp("1.2.3", metadata=["foo", "bar"]) == "1.2.3-foo-bar"
    assert serialize_pvp("1.2.3", metadata=[4]) == "1.2.3-4"

    with pytest.raises(ValueError):
        serialize_pvp("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_pvp():
    assert serialize_pvp("1") == "1"
    assert serialize_pvp("1.2") == "1.2"
    assert serialize_pvp("1.2.3") == "1.2.3"
    assert serialize_pvp("1.2.3.4") == "1.2.3.4"
    assert serialize_pvp("1.2.3", metadata=["foo"]) == "1.2.3-foo"
    assert serialize_pvp("1.2.3", metadata=["foo", "bar"]) == "1.2.3-foo-bar"
    assert serialize_pvp("1.2.3", metadata=[4]) == "1.2.3-4"

    with pytest.raises(ValueError):
        serialize_pvp("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_pvp():
    assert serialize_pvp("1") == "1"
    assert serialize_pvp("1.2") == "1.2"
    assert serialize_pvp("1.2.3") == "1.2.3"
    assert serialize_pvp("1.2.3.4") == "1.2.3.4"
    assert serialize_pvp("1.2.3", metadata=["foo"]) == "1.2.3-foo"
    assert serialize_pvp("1.2.3", metadata=["foo", "bar"]) == "1.2.3-foo-bar"
    assert serialize_pvp("1.2.3", metadata=[4]) == "1.2.3-4"

    with pytest.raises(ValueError):
        serialize_pvp("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_pvp():
    assert serialize_pvp("1") == "1"
    assert serialize_pvp("1.2") == "1.2"
    assert serialize_pvp("1.2.3") == "1.2.3"
    assert serialize_pvp("1.2.3.4") == "1.2.3.4"
    assert serialize_pvp("1.2.3", metadata=["foo"]) == "1.2.3-foo"
    assert serialize_pvp("1.2.3", metadata=["foo", "bar"]) == "1.2.3-foo-bar"
    assert serialize_pvp("1.2.3", metadata=[4]) == "1.2.3-4"

    with pytest.raises(ValueError):
        serialize_pvp("foo")
github mtkennerly / poetry-dynamic-versioning / poetry_dynamic_versioning / __init__.py View on Github external
version = Version.from_vcs(
        vcs, config["pattern"], config["latest-tag"], config["subversion"]["tag-dir"]
    )
    if config["format-jinja"]:
        default_context = {
            "base": version.base,
            "stage": version.stage,
            "revision": version.revision,
            "distance": version.distance,
            "commit": version.commit,
            "dirty": version.dirty,
            "env": os.environ,
            "bump_version": bump_version,
            "serialize_pep440": serialize_pep440,
            "serialize_pvp": serialize_pvp,
            "serialize_semver": serialize_semver,
        }
        custom_context = {}  # type: dict
        for entry in config["format-jinja-imports"]:
            if "module" in entry:
                module = import_module(entry["module"])
                if "item" in entry:
                    custom_context[entry["item"]] = getattr(module, entry["item"])
                else:
                    custom_context[entry["module"]] = module
        serialized = jinja2.Template(config["format-jinja"]).render(
            **default_context, **custom_context
        )
        if style is not None:
            check_version(serialized, style)
    else: