pytest-codeblock 0.5__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_codeblock-0.5/src/pytest_codeblock.egg-info → pytest_codeblock-0.5.2}/PKG-INFO +3 -1
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/pyproject.toml +48 -2
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/__init__.py +17 -1
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/rst.py +2 -2
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_nameless_codeblocks.py +45 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2/src/pytest_codeblock.egg-info}/PKG-INFO +3 -1
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/SOURCES.txt +0 -1
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/requires.txt +2 -0
- pytest_codeblock-0.5/src/pytest_codeblock/tests/conftest.py +0 -62
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/LICENSE +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/README.rst +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/setup.cfg +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/collector.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/config.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/constants.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/helpers.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/md.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/__init__.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_customisation.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_integration.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_pytest_codeblock.py +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/dependency_links.txt +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/entry_points.txt +0 -0
- {pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-codeblock
|
|
3
|
-
Version: 0.5
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Pytest plugin to collect and test code blocks in reStructuredText and Markdown files.
|
|
5
5
|
Author-email: Artur Barseghyan <artur.barseghyan@gmail.com>
|
|
6
6
|
Maintainer-email: Artur Barseghyan <artur.barseghyan@gmail.com>
|
|
@@ -47,12 +47,14 @@ Requires-Dist: openai; extra == "test"
|
|
|
47
47
|
Requires-Dist: pytest; extra == "test"
|
|
48
48
|
Requires-Dist: pytest-cov; extra == "test"
|
|
49
49
|
Requires-Dist: pytest-django; extra == "test"
|
|
50
|
+
Requires-Dist: respx; extra == "test"
|
|
50
51
|
Provides-Extra: docs
|
|
51
52
|
Requires-Dist: sphinx; extra == "docs"
|
|
52
53
|
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
53
54
|
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
54
55
|
Requires-Dist: sphinx-no-pragma; extra == "docs"
|
|
55
56
|
Requires-Dist: sphinx-llms-txt-link; extra == "docs"
|
|
57
|
+
Requires-Dist: sphinx-source-tree; extra == "docs"
|
|
56
58
|
Provides-Extra: build
|
|
57
59
|
Requires-Dist: build; extra == "build"
|
|
58
60
|
Requires-Dist: twine; extra == "build"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "pytest-codeblock"
|
|
3
3
|
description = "Pytest plugin to collect and test code blocks in reStructuredText and Markdown files."
|
|
4
4
|
readme = "README.rst"
|
|
5
|
-
version = "0.5"
|
|
5
|
+
version = "0.5.2"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"pytest",
|
|
@@ -65,6 +65,7 @@ test = [
|
|
|
65
65
|
"pytest",
|
|
66
66
|
"pytest-cov",
|
|
67
67
|
"pytest-django",
|
|
68
|
+
"respx",
|
|
68
69
|
]
|
|
69
70
|
docs = [
|
|
70
71
|
"sphinx",
|
|
@@ -72,6 +73,7 @@ docs = [
|
|
|
72
73
|
"sphinx-rtd-theme>=1.3.0",
|
|
73
74
|
"sphinx-no-pragma",
|
|
74
75
|
"sphinx-llms-txt-link",
|
|
76
|
+
"sphinx-source-tree",
|
|
75
77
|
# "standard-imghdr",
|
|
76
78
|
]
|
|
77
79
|
build = [
|
|
@@ -194,7 +196,7 @@ DJANGO_SETTINGS_MODULE = "django_settings"
|
|
|
194
196
|
|
|
195
197
|
markers = [
|
|
196
198
|
"slow: mark a test that takes a long time to run.",
|
|
197
|
-
"codeblock: pytest-codeblock markers",
|
|
199
|
+
# "codeblock: pytest-codeblock markers",
|
|
198
200
|
"aws: mark test as a AWS test",
|
|
199
201
|
"documentation: mark test as a documentation test",
|
|
200
202
|
"fakepy: mark test as a fake.py test",
|
|
@@ -225,3 +227,47 @@ exclude = "\\.git|\\.tox|tests/data|\\.venv"
|
|
|
225
227
|
require-return-section-when-returning-nothing = false
|
|
226
228
|
allow-init-docstring = true
|
|
227
229
|
arg-type-hints-in-docstring = false
|
|
230
|
+
|
|
231
|
+
[tool.sphinx-source-tree]
|
|
232
|
+
ignore = [
|
|
233
|
+
"__pycache__",
|
|
234
|
+
"*.pyc",
|
|
235
|
+
"*.pyo",
|
|
236
|
+
"*.py,cover",
|
|
237
|
+
".git",
|
|
238
|
+
".hg",
|
|
239
|
+
".svn",
|
|
240
|
+
".tox",
|
|
241
|
+
".nox",
|
|
242
|
+
".venv",
|
|
243
|
+
"venv",
|
|
244
|
+
"env",
|
|
245
|
+
"*.egg-info",
|
|
246
|
+
"dist",
|
|
247
|
+
"build",
|
|
248
|
+
"node_modules",
|
|
249
|
+
".mypy_cache",
|
|
250
|
+
".pytest_cache",
|
|
251
|
+
".coverage",
|
|
252
|
+
"htmlcov",
|
|
253
|
+
".idea",
|
|
254
|
+
".vscode",
|
|
255
|
+
".DS_Store",
|
|
256
|
+
"Thumbs.db",
|
|
257
|
+
".ruff_cache",
|
|
258
|
+
".coverage.*",
|
|
259
|
+
".secrets.baseline",
|
|
260
|
+
".pre-commit-config.yaml",
|
|
261
|
+
".pre-commit-hooks.yaml",
|
|
262
|
+
".readthedocs.yaml",
|
|
263
|
+
"CHANGELOG.rst",
|
|
264
|
+
"CODE_OF_CONDUCT.rst",
|
|
265
|
+
"LICENSE",
|
|
266
|
+
"SECURITY.rst",
|
|
267
|
+
"docs/changelog.rst",
|
|
268
|
+
"docs/code_of_conduct.rst",
|
|
269
|
+
"docs/security.rst",
|
|
270
|
+
"docs/source_tree.rst",
|
|
271
|
+
"docs/make.bat",
|
|
272
|
+
"docs/Makefile",
|
|
273
|
+
]
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
3
|
from .config import get_config
|
|
4
|
+
from .constants import CODEBLOCK_MARK
|
|
4
5
|
from .md import MarkdownFile
|
|
5
6
|
from .rst import RSTFile
|
|
6
7
|
|
|
7
8
|
__title__ = "pytest-codeblock"
|
|
8
|
-
__version__ = "0.5"
|
|
9
|
+
__version__ = "0.5.2"
|
|
9
10
|
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
|
10
11
|
__copyright__ = "2025-2026 Artur Barseghyan"
|
|
11
12
|
__license__ = "MIT"
|
|
12
13
|
__all__ = (
|
|
13
14
|
"pytest_collect_file",
|
|
15
|
+
"pytest_configure",
|
|
14
16
|
)
|
|
15
17
|
|
|
16
18
|
|
|
@@ -26,3 +28,17 @@ def pytest_collect_file(parent, path):
|
|
|
26
28
|
# Use the RSTFile collector for reStructuredText files
|
|
27
29
|
return RSTFile.from_parent(parent=parent, path=Path(path))
|
|
28
30
|
return None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def pytest_configure(config):
|
|
34
|
+
"""Register the codeblock marker if not already registered."""
|
|
35
|
+
# Get existing markers
|
|
36
|
+
existing_markers = config.getini("markers")
|
|
37
|
+
marker_names = [m.split(":")[0].strip() for m in existing_markers]
|
|
38
|
+
|
|
39
|
+
# Only register if not already present
|
|
40
|
+
if CODEBLOCK_MARK not in marker_names:
|
|
41
|
+
config.addinivalue_line(
|
|
42
|
+
"markers",
|
|
43
|
+
f"{CODEBLOCK_MARK}: pytest-codeblock markers (auto-registered)",
|
|
44
|
+
)
|
|
@@ -211,7 +211,7 @@ def parse_rst(text: str, base_dir: Path) -> list[CodeSnippet]:
|
|
|
211
211
|
sn_marks = pending_marks.copy()
|
|
212
212
|
sn_fixtures = pending_fixtures.copy()
|
|
213
213
|
pending_name = None
|
|
214
|
-
pending_marks
|
|
214
|
+
pending_marks = [CODEBLOCK_MARK] # clear pending marks
|
|
215
215
|
pending_fixtures.clear()
|
|
216
216
|
|
|
217
217
|
snippets.append(CodeSnippet(
|
|
@@ -241,7 +241,7 @@ def parse_rst(text: str, base_dir: Path) -> list[CodeSnippet]:
|
|
|
241
241
|
sn_marks = pending_marks.copy()
|
|
242
242
|
sn_fixtures = pending_fixtures.copy()
|
|
243
243
|
pending_name = None
|
|
244
|
-
pending_marks
|
|
244
|
+
pending_marks = [CODEBLOCK_MARK] # clear pending marks
|
|
245
245
|
pending_fixtures.clear()
|
|
246
246
|
j = i + 1
|
|
247
247
|
if j < n and not lines[j].strip():
|
|
@@ -16,6 +16,7 @@ import pytest
|
|
|
16
16
|
|
|
17
17
|
from ..collector import group_snippets
|
|
18
18
|
from ..config import Config
|
|
19
|
+
from ..constants import CODEBLOCK_MARK
|
|
19
20
|
from ..md import parse_markdown
|
|
20
21
|
from ..rst import parse_rst
|
|
21
22
|
|
|
@@ -311,6 +312,27 @@ user = User.objects.first()
|
|
|
311
312
|
|
|
312
313
|
# -------------------------------------------------------------------------
|
|
313
314
|
|
|
315
|
+
def test_codeblock_marks_on_all_blocks(self):
|
|
316
|
+
"""Test that all blocks have default codeblock marks."""
|
|
317
|
+
text = """
|
|
318
|
+
```python
|
|
319
|
+
assert True
|
|
320
|
+
```
|
|
321
|
+
```python
|
|
322
|
+
assert True
|
|
323
|
+
```
|
|
324
|
+
"""
|
|
325
|
+
mock_config = Config(test_nameless_codeblocks=True)
|
|
326
|
+
|
|
327
|
+
with patch("pytest_codeblock.md.get_config", return_value=mock_config):
|
|
328
|
+
raw = parse_markdown(text)
|
|
329
|
+
|
|
330
|
+
assert len(raw) == 2
|
|
331
|
+
for sn in raw:
|
|
332
|
+
assert CODEBLOCK_MARK in sn.marks
|
|
333
|
+
|
|
334
|
+
# -------------------------------------------------------------------------
|
|
335
|
+
|
|
314
336
|
def test_auto_naming_preserves_fixtures(self):
|
|
315
337
|
"""Test that auto-naming preserves pytest fixtures."""
|
|
316
338
|
text = """
|
|
@@ -551,6 +573,29 @@ class TestRSTNameless:
|
|
|
551
573
|
|
|
552
574
|
# -------------------------------------------------------------------------
|
|
553
575
|
|
|
576
|
+
def test_codeblock_marks_on_all_blocks_rst(self, tmp_path):
|
|
577
|
+
"""Test that all blocks in RST file have default codeblock mark."""
|
|
578
|
+
text = """
|
|
579
|
+
.. code-block:: python
|
|
580
|
+
assert True
|
|
581
|
+
|
|
582
|
+
.. code-block::python
|
|
583
|
+
assert True
|
|
584
|
+
|
|
585
|
+
"""
|
|
586
|
+
mock_config = Config(test_nameless_codeblocks=True)
|
|
587
|
+
|
|
588
|
+
with patch(
|
|
589
|
+
"pytest_codeblock.rst.get_config", return_value=mock_config
|
|
590
|
+
):
|
|
591
|
+
raw = parse_rst(text, tmp_path)
|
|
592
|
+
|
|
593
|
+
assert len(raw) == 2
|
|
594
|
+
for sn in raw:
|
|
595
|
+
assert CODEBLOCK_MARK in sn.marks
|
|
596
|
+
|
|
597
|
+
# -------------------------------------------------------------------------
|
|
598
|
+
|
|
554
599
|
def test_auto_naming_preserves_fixtures_rst(self, tmp_path):
|
|
555
600
|
"""Test that auto-naming preserves pytest fixtures in RST."""
|
|
556
601
|
text = """
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-codeblock
|
|
3
|
-
Version: 0.5
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Pytest plugin to collect and test code blocks in reStructuredText and Markdown files.
|
|
5
5
|
Author-email: Artur Barseghyan <artur.barseghyan@gmail.com>
|
|
6
6
|
Maintainer-email: Artur Barseghyan <artur.barseghyan@gmail.com>
|
|
@@ -47,12 +47,14 @@ Requires-Dist: openai; extra == "test"
|
|
|
47
47
|
Requires-Dist: pytest; extra == "test"
|
|
48
48
|
Requires-Dist: pytest-cov; extra == "test"
|
|
49
49
|
Requires-Dist: pytest-django; extra == "test"
|
|
50
|
+
Requires-Dist: respx; extra == "test"
|
|
50
51
|
Provides-Extra: docs
|
|
51
52
|
Requires-Dist: sphinx; extra == "docs"
|
|
52
53
|
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
53
54
|
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
54
55
|
Requires-Dist: sphinx-no-pragma; extra == "docs"
|
|
55
56
|
Requires-Dist: sphinx-llms-txt-link; extra == "docs"
|
|
57
|
+
Requires-Dist: sphinx-source-tree; extra == "docs"
|
|
56
58
|
Provides-Extra: build
|
|
57
59
|
Requires-Dist: build; extra == "build"
|
|
58
60
|
Requires-Dist: twine; extra == "build"
|
|
@@ -15,7 +15,6 @@ src/pytest_codeblock.egg-info/entry_points.txt
|
|
|
15
15
|
src/pytest_codeblock.egg-info/requires.txt
|
|
16
16
|
src/pytest_codeblock.egg-info/top_level.txt
|
|
17
17
|
src/pytest_codeblock/tests/__init__.py
|
|
18
|
-
src/pytest_codeblock/tests/conftest.py
|
|
19
18
|
src/pytest_codeblock/tests/test_customisation.py
|
|
20
19
|
src/pytest_codeblock/tests/test_integration.py
|
|
21
20
|
src/pytest_codeblock/tests/test_nameless_codeblocks.py
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
from types import SimpleNamespace
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
|
6
|
-
__copyright__ = "2025-2026 Artur Barseghyan"
|
|
7
|
-
__license__ = "MIT"
|
|
8
|
-
__all__ = (
|
|
9
|
-
"http_request_factory",
|
|
10
|
-
"http_request",
|
|
11
|
-
"markdown_simple",
|
|
12
|
-
"markdown_with_pytest_mark",
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
pytest_plugins = ["pytester"]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@pytest.fixture
|
|
20
|
-
def http_request_factory():
|
|
21
|
-
"""
|
|
22
|
-
Returns a function that creates a simple namespace object
|
|
23
|
-
with a 'GET' attribute set to the provided dictionary.
|
|
24
|
-
"""
|
|
25
|
-
def _factory(get_data: dict):
|
|
26
|
-
# Creates an object like: object(GET={'key': 'value'})
|
|
27
|
-
return SimpleNamespace(GET=get_data)
|
|
28
|
-
return _factory
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@pytest.fixture
|
|
32
|
-
def http_request(http_request_factory):
|
|
33
|
-
test_data = {"param1": "value1", "signature": "mock-sig"}
|
|
34
|
-
return http_request_factory(test_data)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@pytest.fixture
|
|
38
|
-
def markdown_simple():
|
|
39
|
-
return """
|
|
40
|
-
```python name=test_example
|
|
41
|
-
x=1
|
|
42
|
-
assert x==1
|
|
43
|
-
```"""
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@pytest.fixture
|
|
47
|
-
def markdown_with_pytest_mark():
|
|
48
|
-
return """
|
|
49
|
-
<!-- pytestmark: django_db -->
|
|
50
|
-
```python name=test_db
|
|
51
|
-
from django.db import models
|
|
52
|
-
```"""
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@pytest.fixture
|
|
56
|
-
def pytester_subprocess(pytester):
|
|
57
|
-
"""
|
|
58
|
-
Wrapper that forces subprocess mode to avoid deprecation warning conflicts
|
|
59
|
-
when the plugin uses the old `path` argument signature.
|
|
60
|
-
"""
|
|
61
|
-
pytester.runpytest = pytester.runpytest_subprocess
|
|
62
|
-
return pytester
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_customisation.py
RENAMED
|
File without changes
|
{pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_integration.py
RENAMED
|
File without changes
|
{pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock/tests/test_pytest_codeblock.py
RENAMED
|
File without changes
|
{pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{pytest_codeblock-0.5 → pytest_codeblock-0.5.2}/src/pytest_codeblock.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|