diff --git a/pyproject.toml b/pyproject.toml index 5ddae880..df44491f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ rtd = [ ] testing = [ "coverage", + "flit_core>=3.4,<5", # lets tests/test_packaging build the sdist "pytest", "pytest-cov", "pytest-regressions", @@ -81,9 +82,12 @@ markdown-it = "markdown_it.cli.parse:main" name = "markdown_it" [tool.flit.sdist] +include = [ + "tests/", + "tox.ini", +] exclude = [ "docs/", - "tests/", "benchmarking/" ] diff --git a/tests/test_packaging/test_sdist_includes_tests.py b/tests/test_packaging/test_sdist_includes_tests.py new file mode 100644 index 00000000..b16118a3 --- /dev/null +++ b/tests/test_packaging/test_sdist_includes_tests.py @@ -0,0 +1,28 @@ +"""Regression for https://github.com/executablebooks/markdown-it-py/issues/261.""" + +from __future__ import annotations + +from pathlib import Path +import tarfile + +import pytest + +ROOT = Path(__file__).resolve().parents[2] + + +def test_sdist_contents(tmp_path: Path) -> None: + """The sdist must ship tests/ and tox.ini, so downstream packagers can run them.""" + flit_sdist = pytest.importorskip("flit_core.sdist") + if not (ROOT / "pyproject.toml").is_file(): + pytest.skip("not running from a source checkout") + + builder = flit_sdist.SdistBuilder.from_ini_path(ROOT / "pyproject.toml") + with tarfile.open(builder.build(tmp_path)) as tar: + # strip the leading `markdown_it-/` component + names = {name.split("/", 1)[1] for name in tar.getnames() if "/" in name} + + assert "markdown_it/__init__.py" in names + assert "tests/test_api/test_main.py" in names + assert "tox.ini" in names + # heavy, non-essential trees are still excluded + assert not [name for name in names if name.startswith(("docs/", "benchmarking/"))]