Skip to content

Commit e87e5da

Browse files
committed
🔀 MERGE: master into maint/release-v0.7.0 (#170)
2 parents 13974a7 + 1478f5b commit e87e5da

8 files changed

Lines changed: 80 additions & 16 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
strategy:
3434
fail-fast: false
3535
matrix:
36-
python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13']
36+
python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13', '3.14']
3737

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

62+
tests-floor:
63+
64+
# the oldest markdown-it-py the package declares (`markdown-it-py>=3.0.0`):
65+
# the plugins that need 4.1 skip their tests and check their version guard
66+
name: tests (3.10, markdown-it-py 3.0.0)
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Set up Python 3.10
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: "3.10"
75+
- name: Install dependencies
76+
run: |
77+
python -m pip install --upgrade pip
78+
pip install -e .[testing] markdown-it-py==3.0.0
79+
- name: Check the installed markdown-it-py
80+
run: python -c "import markdown_it; assert markdown_it.__version__ == '3.0.0', markdown_it.__version__"
81+
- name: Run pytest
82+
run: pytest
83+
6284
build:
6385

6486
name: Build distributions
@@ -103,14 +125,15 @@ jobs:
103125
needs:
104126
- pre-commit
105127
- tests
128+
- tests-floor
106129
- build
107130
steps:
108131
- run: echo "Great success!"
109132

110133
publish:
111134

112135
name: Publish to PyPI
113-
needs: [pre-commit, tests, build]
136+
needs: [pre-commit, tests, tests-floor, build]
114137
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
115138
runs-on: ubuntu-latest
116139
permissions:

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ repos:
3030
rev: v2.4.1
3131
hooks:
3232
- id: mypy
33-
additional_dependencies: [markdown-it-py~=3.0]
33+
additional_dependencies: [markdown-it-py~=4.2]
3434
exclude: ^tests/

‎pyproject.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ classifiers = [
1414
"Intended Audience :: Developers",
1515
"License :: OSI Approved :: MIT License",
1616
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3.8",
18-
"Programming Language :: Python :: 3.9",
1917
"Programming Language :: Python :: 3.10",
2018
"Programming Language :: Python :: 3.11",
2119
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
"Programming Language :: Python :: 3.14",
2222
"Programming Language :: Python :: Implementation :: CPython",
2323
"Programming Language :: Python :: Implementation :: PyPy",
2424
"Topic :: Software Development :: Libraries :: Python Modules",
2525
"Topic :: Text Processing :: Markup",
2626
]
2727
keywords = ["markdown", "markdown-it", "lexer", "parser", "development"]
2828
requires-python = ">=3.10"
29-
dependencies = ["markdown-it-py>=2.0.0,<5.0.0"]
29+
dependencies = ["markdown-it-py>=3.0.0,<5.0.0"]
3030

3131
[project.urls]
3232
Homepage = "https://github.com/executablebooks/mdit-py-plugins"

‎tests/test_gfm.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
from mdit_py_plugins.gfm import gfm_plugin
1010

11+
# The plugin needs markdown-it-py >= 4.1.0 (it raises RuntimeError below that);
12+
# the guard itself is tested in test_mdit_version_guard.py, on every version.
13+
pytest.importorskip("markdown_it", minversion="4.1.0")
14+
1115
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "gfm.md")
1216

1317

‎tests/test_gfm_autolink.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
from mdit_py_plugins.gfm_autolink import gfm_autolink_plugin
1010

11+
# The plugin needs markdown-it-py >= 4.1.0 (it raises RuntimeError below that);
12+
# the guard itself is tested in test_mdit_version_guard.py, on every version.
13+
pytest.importorskip("markdown_it", minversion="4.1.0")
14+
1115
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "gfm_autolink.md")
1216

1317

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""The plugins that need markdown-it-py >= 4.1.0 refuse older versions.
2+
3+
``test_gfm``, ``test_gfm_autolink`` and ``test_section_ref`` skip below 4.1.0,
4+
so their version guards are tested here, where they run on every supported version
5+
(CI runs the suite on the declared floor, markdown-it-py 3.0.0, as well as the latest).
6+
"""
7+
8+
from types import SimpleNamespace
9+
10+
from markdown_it import MarkdownIt
11+
from markdown_it import __version__ as mdit_version
12+
from packaging.version import Version
13+
import pytest
14+
15+
from mdit_py_plugins.gfm import gfm_plugin
16+
from mdit_py_plugins.gfm_autolink import gfm_autolink_plugin
17+
from mdit_py_plugins.section_ref import section_ref_plugin
18+
19+
20+
@pytest.mark.skipif(
21+
Version(mdit_version) >= Version("4.1.0"),
22+
reason="needs markdown-it-py < 4.1.0 installed",
23+
)
24+
@pytest.mark.parametrize(
25+
"plugin", [gfm_plugin, gfm_autolink_plugin, section_ref_plugin]
26+
)
27+
def test_raises_below_4_1(plugin):
28+
"""On markdown-it-py < 4.1.0 the plugin raises a clear error, not a late failure."""
29+
with pytest.raises(RuntimeError, match=r"requires markdown-it-py >= 4\.1\.0"):
30+
MarkdownIt().use(plugin)
31+
32+
33+
def test_section_ref_runtime_error():
34+
"""The plugin requires the ``add_terminator_char`` API (markdown-it-py >= 4.1.0)."""
35+
md = MarkdownIt()
36+
md.inline = SimpleNamespace() # type: ignore[assignment] # lacks add_terminator_char
37+
with pytest.raises(RuntimeError, match="requires markdown-it-py"):
38+
section_ref_plugin(md)

‎tests/test_section_ref.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22
import time
3-
from types import SimpleNamespace
43

54
from markdown_it import MarkdownIt
65
from markdown_it.token import Token
@@ -9,6 +8,10 @@
98

109
from mdit_py_plugins.section_ref import section_ref_plugin
1110

11+
# The plugin needs markdown-it-py >= 4.1.0 (it raises RuntimeError below that);
12+
# the guard itself is tested in test_mdit_version_guard.py, on every version.
13+
pytest.importorskip("markdown_it", minversion="4.1.0")
14+
1215
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures", "section_ref.md")
1316

1417

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

135138

136-
def test_runtime_error():
137-
"""The plugin requires the ``add_terminator_char`` API (markdown-it-py >= 4.1.0)."""
138-
md = MarkdownIt()
139-
md.inline = SimpleNamespace() # type: ignore[assignment] # lacks add_terminator_char
140-
with pytest.raises(RuntimeError, match="requires markdown-it-py"):
141-
section_ref_plugin(md)
142-
143-
144139
@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH))
145140
def test_all(line, title, input, expected):
146141
md = MarkdownIt("commonmark").use(section_ref_plugin)

‎tox.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ envlist = py310
99
[testenv]
1010
usedevelop = true
1111

12-
[testenv:py{310,311,312,313}]
12+
[testenv:py{310,311,312,313,314}]
1313
extras = testing
1414
deps = markdown-it-py>=4.1.0
1515
commands = pytest {posargs}

0 commit comments

Comments
 (0)