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
27 changes: 25 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13']
python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v4
Expand All @@ -59,6 +59,28 @@ jobs:
# coverage is informational: an upload failure must not fail CI
fail_ci_if_error: false

tests-floor:

# the oldest markdown-it-py the package declares (`markdown-it-py>=3.0.0`):
# the plugins that need 4.1 skip their tests and check their version guard
name: tests (3.10, markdown-it-py 3.0.0)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[testing] markdown-it-py==3.0.0
- name: Check the installed markdown-it-py
run: python -c "import markdown_it; assert markdown_it.__version__ == '3.0.0', markdown_it.__version__"
- name: Run pytest
run: pytest

build:

name: Build distributions
Expand Down Expand Up @@ -103,14 +125,15 @@ jobs:
needs:
- pre-commit
- tests
- tests-floor
- build
steps:
- run: echo "Great success!"

publish:

name: Publish to PyPI
needs: [pre-commit, tests, build]
needs: [pre-commit, tests, tests-floor, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ repos:
rev: v2.4.1
hooks:
- id: mypy
additional_dependencies: [markdown-it-py~=3.0]
additional_dependencies: [markdown-it-py~=4.2]
exclude: ^tests/
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
]
keywords = ["markdown", "markdown-it", "lexer", "parser", "development"]
requires-python = ">=3.10"
dependencies = ["markdown-it-py>=2.0.0,<5.0.0"]
dependencies = ["markdown-it-py>=3.0.0,<5.0.0"]

[project.urls]
Homepage = "https://github.com/executablebooks/mdit-py-plugins"
Expand Down
4 changes: 4 additions & 0 deletions tests/test_gfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

from mdit_py_plugins.gfm import gfm_plugin

# The plugin needs markdown-it-py >= 4.1.0 (it raises RuntimeError below that);
# the guard itself is tested in test_mdit_version_guard.py, on every version.
pytest.importorskip("markdown_it", minversion="4.1.0")

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "gfm.md")


Expand Down
4 changes: 4 additions & 0 deletions tests/test_gfm_autolink.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

from mdit_py_plugins.gfm_autolink import gfm_autolink_plugin

# The plugin needs markdown-it-py >= 4.1.0 (it raises RuntimeError below that);
# the guard itself is tested in test_mdit_version_guard.py, on every version.
pytest.importorskip("markdown_it", minversion="4.1.0")

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "gfm_autolink.md")


Expand Down
38 changes: 38 additions & 0 deletions tests/test_mdit_version_guard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""The plugins that need markdown-it-py >= 4.1.0 refuse older versions.

``test_gfm``, ``test_gfm_autolink`` and ``test_section_ref`` skip below 4.1.0,
so their version guards are tested here, where they run on every supported version
(CI runs the suite on the declared floor, markdown-it-py 3.0.0, as well as the latest).
"""

from types import SimpleNamespace

from markdown_it import MarkdownIt
from markdown_it import __version__ as mdit_version
from packaging.version import Version
import pytest

from mdit_py_plugins.gfm import gfm_plugin
from mdit_py_plugins.gfm_autolink import gfm_autolink_plugin
from mdit_py_plugins.section_ref import section_ref_plugin


@pytest.mark.skipif(
Version(mdit_version) >= Version("4.1.0"),
reason="needs markdown-it-py < 4.1.0 installed",
)
@pytest.mark.parametrize(
"plugin", [gfm_plugin, gfm_autolink_plugin, section_ref_plugin]
)
def test_raises_below_4_1(plugin):
"""On markdown-it-py < 4.1.0 the plugin raises a clear error, not a late failure."""
with pytest.raises(RuntimeError, match=r"requires markdown-it-py >= 4\.1\.0"):
MarkdownIt().use(plugin)


def test_section_ref_runtime_error():
"""The plugin requires the ``add_terminator_char`` API (markdown-it-py >= 4.1.0)."""
md = MarkdownIt()
md.inline = SimpleNamespace() # type: ignore[assignment] # lacks add_terminator_char
with pytest.raises(RuntimeError, match="requires markdown-it-py"):
section_ref_plugin(md)
13 changes: 4 additions & 9 deletions tests/test_section_ref.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path
import time
from types import SimpleNamespace

from markdown_it import MarkdownIt
from markdown_it.token import Token
Expand All @@ -9,6 +8,10 @@

from mdit_py_plugins.section_ref import section_ref_plugin

# The plugin needs markdown-it-py >= 4.1.0 (it raises RuntimeError below that);
# the guard itself is tested in test_mdit_version_guard.py, on every version.
pytest.importorskip("markdown_it", minversion="4.1.0")

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "section_ref.md")


Expand Down Expand Up @@ -133,14 +136,6 @@ def test_token_shape_is_public_api():
assert token.meta == {"numbers": [1, 2]}


def test_runtime_error():
"""The plugin requires the ``add_terminator_char`` API (markdown-it-py >= 4.1.0)."""
md = MarkdownIt()
md.inline = SimpleNamespace() # type: ignore[assignment] # lacks add_terminator_char
with pytest.raises(RuntimeError, match="requires markdown-it-py"):
section_ref_plugin(md)


@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH))
def test_all(line, title, input, expected):
md = MarkdownIt("commonmark").use(section_ref_plugin)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ envlist = py310
[testenv]
usedevelop = true

[testenv:py{310,311,312,313}]
[testenv:py{310,311,312,313,314}]
extras = testing
deps = markdown-it-py>=4.1.0
commands = pytest {posargs}
Expand Down
Loading