diff --git a/tests/project-pep621/pyproject.toml b/tests/project-pep621/pyproject.toml index 201aa6c..eec1826 100644 --- a/tests/project-pep621/pyproject.toml +++ b/tests/project-pep621/pyproject.toml @@ -2,6 +2,11 @@ name = "project-pep621" dynamic = ["version"] +[tool.poetry] +# The plugin itself doesn't need this, but Poetry does: +# https://github.com/python-poetry/poetry-core/blob/c80dcc53793316104862d2c3ac888dde3c263b08/tests/test_factory.py#L39-L42 +version = "0.0.0" + [tool.poetry-dynamic-versioning] enable = true diff --git a/tests/test_integration.py b/tests/test_integration.py index 36f8b3d..e2d073b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -18,6 +18,7 @@ DUMMY_PYPROJECT = DUMMY / "pyproject.toml" DUMMY_PEP621 = ROOT / "tests" / "project-pep621" +DUMMY_PEP621_DIST = DUMMY_PEP621 / "dist" DUMMY_PEP621_PYPROJECT = DUMMY_PEP621 / "pyproject.toml" DUMMY_VERSION = "0.0.999" @@ -288,6 +289,20 @@ def test_pep621_with_dynamic_version(): ).read_bytes().decode("utf-8") +@pytest.mark.skipif("USE_PEP621" not in os.environ, reason="Requires Poetry with PEP-621 support") +def test_pep621_with_dynamic_version_and_cleanup(): + version = dunamai.Version.from_git().serialize() + + run("poetry build", where=DUMMY_PEP621) + assert 'version = "0.0.0"' in DUMMY_PEP621_PYPROJECT.read_bytes().decode("utf-8") + assert '__version__ = "0.0.0"' in ( + DUMMY_PEP621 / "project_pep621" / "__init__.py" + ).read_bytes().decode("utf-8") + + artifact = next(DUMMY_PEP621_DIST.glob("*.whl")) + assert f"-{version}-" in artifact.name + + @pytest.mark.skipif("USE_PEP621" not in os.environ, reason="Requires Poetry with PEP-621 support") def test_pep621_without_dynamic_version(): data = DUMMY_PEP621_PYPROJECT.read_bytes().decode("utf-8")