Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ rtd = [
]
testing = [
"coverage",
"flit_core>=3.4,<5", # lets tests/test_packaging build the sdist
"pytest",
"pytest-cov",
"pytest-regressions",
Expand All @@ -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/"
]

Expand Down
28 changes: 28 additions & 0 deletions tests/test_packaging/test_sdist_includes_tests.py
Original file line number Diff line number Diff line change
@@ -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-<version>/` 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/"))]
Loading