Skip to content

Commit

Permalink
Add test case for 'poetry build'
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jun 17, 2024
1 parent decb8b3 commit 160e8a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/project-pep621/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 160e8a9

Please sign in to comment.