pytest-codeblock 0.1.3__tar.gz → 0.1.5__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.1.3/pytest_codeblock.egg-info → pytest_codeblock-0.1.5}/PKG-INFO +6 -2
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/README.rst +5 -1
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pyproject.toml +1 -1
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock/__init__.py +1 -1
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock/rst.py +30 -5
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5/pytest_codeblock.egg-info}/PKG-INFO +6 -2
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/LICENSE +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock/collector.py +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock/constants.py +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock/md.py +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/SOURCES.txt +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/dependency_links.txt +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/entry_points.txt +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/requires.txt +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/top_level.txt +0 -0
- {pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-codeblock
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
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>
|
|
@@ -81,7 +81,7 @@ pytest-codeblock
|
|
|
81
81
|
.. _Examples: https://github.com/barseghyanartur/pytest-codeblock/tree/main/examples
|
|
82
82
|
.. _Contributor guidelines: https://pytest-codeblock.readthedocs.io/en/latest/contributor_guidelines.html
|
|
83
83
|
|
|
84
|
-
Test your code blocks.
|
|
84
|
+
Test your documentation code blocks.
|
|
85
85
|
|
|
86
86
|
.. image:: https://img.shields.io/pypi/v/pytest-codeblock.svg
|
|
87
87
|
:target: https://pypi.python.org/pypi/pytest-codeblock
|
|
@@ -266,6 +266,8 @@ Any fenced code block with a recognized Python language tag (e.g., ``python``,
|
|
|
266
266
|
assert result == 9
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
+
----
|
|
270
|
+
|
|
269
271
|
**Grouping example**
|
|
270
272
|
|
|
271
273
|
.. code-block:: markdown
|
|
@@ -280,6 +282,8 @@ Any fenced code block with a recognized Python language tag (e.g., ``python``,
|
|
|
280
282
|
print(x + 1) # Uses x from the first snippet
|
|
281
283
|
```
|
|
282
284
|
|
|
285
|
+
----
|
|
286
|
+
|
|
283
287
|
**pytest marks**
|
|
284
288
|
|
|
285
289
|
.. code-block:: markdown
|
|
@@ -22,7 +22,7 @@ pytest-codeblock
|
|
|
22
22
|
.. _Examples: https://github.com/barseghyanartur/pytest-codeblock/tree/main/examples
|
|
23
23
|
.. _Contributor guidelines: https://pytest-codeblock.readthedocs.io/en/latest/contributor_guidelines.html
|
|
24
24
|
|
|
25
|
-
Test your code blocks.
|
|
25
|
+
Test your documentation code blocks.
|
|
26
26
|
|
|
27
27
|
.. image:: https://img.shields.io/pypi/v/pytest-codeblock.svg
|
|
28
28
|
:target: https://pypi.python.org/pypi/pytest-codeblock
|
|
@@ -207,6 +207,8 @@ Any fenced code block with a recognized Python language tag (e.g., ``python``,
|
|
|
207
207
|
assert result == 9
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
+
----
|
|
211
|
+
|
|
210
212
|
**Grouping example**
|
|
211
213
|
|
|
212
214
|
.. code-block:: markdown
|
|
@@ -221,6 +223,8 @@ Any fenced code block with a recognized Python language tag (e.g., ``python``,
|
|
|
221
223
|
print(x + 1) # Uses x from the first snippet
|
|
222
224
|
```
|
|
223
225
|
|
|
226
|
+
----
|
|
227
|
+
|
|
224
228
|
**pytest marks**
|
|
225
229
|
|
|
226
230
|
.. code-block:: markdown
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pytest-codeblock"
|
|
3
|
-
version = "0.1.3"
|
|
4
3
|
description = "Pytest plugin to collect and test code blocks in reStructuredText and Markdown files."
|
|
5
4
|
readme = "README.rst"
|
|
5
|
+
version = "0.1.5"
|
|
6
6
|
requires-python = ">=3.9"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"pytest",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import textwrap
|
|
3
|
+
import traceback
|
|
2
4
|
from pathlib import Path
|
|
3
5
|
from typing import Optional
|
|
4
6
|
|
|
@@ -28,8 +30,9 @@ def resolve_literalinclude_path(
|
|
|
28
30
|
if _include_path.exists():
|
|
29
31
|
return str(_include_path.resolve())
|
|
30
32
|
|
|
33
|
+
_base_dir = Path(base_dir.dirname) if base_dir.isfile() else base_dir
|
|
31
34
|
try:
|
|
32
|
-
full_path =
|
|
35
|
+
full_path = _base_dir / include_path
|
|
33
36
|
if full_path.exists():
|
|
34
37
|
return str(full_path.resolve())
|
|
35
38
|
except Exception:
|
|
@@ -256,17 +259,39 @@ class RSTFile(pytest.File):
|
|
|
256
259
|
combined = group_snippets(tests)
|
|
257
260
|
|
|
258
261
|
for sn in combined:
|
|
262
|
+
# Bind the values we need so we don't close over `sn` itself
|
|
263
|
+
_sn_name = sn.name
|
|
264
|
+
_fpath = str(self.fspath)
|
|
265
|
+
|
|
259
266
|
# Create a Python function for this snippet
|
|
260
267
|
if DJANGO_DB_MARKS.intersection(sn.marks):
|
|
261
268
|
# Function *requests* the db fixture
|
|
262
|
-
def make_func(code):
|
|
269
|
+
def make_func(code, sn_name=_sn_name, fpath=_fpath):
|
|
263
270
|
def test_block(db):
|
|
264
|
-
|
|
271
|
+
compiled = compile(code, fpath, "exec")
|
|
272
|
+
try:
|
|
273
|
+
exec(compiled, {})
|
|
274
|
+
except Exception as err:
|
|
275
|
+
raise Exception(
|
|
276
|
+
f"Error in "
|
|
277
|
+
f"codeblock `{sn_name}` in {fpath}:\n"
|
|
278
|
+
f"\n{textwrap.indent(code, prefix=' ')}\n\n"
|
|
279
|
+
f"{traceback.format_exc()}"
|
|
280
|
+
) from err
|
|
265
281
|
return test_block
|
|
266
282
|
else:
|
|
267
|
-
def make_func(code):
|
|
283
|
+
def make_func(code, sn_name=_sn_name, fpath=_fpath):
|
|
268
284
|
def test_block():
|
|
269
|
-
|
|
285
|
+
compiled = compile(code, fpath, "exec")
|
|
286
|
+
try:
|
|
287
|
+
exec(compiled, {})
|
|
288
|
+
except Exception as err:
|
|
289
|
+
raise Exception(
|
|
290
|
+
f"Error in "
|
|
291
|
+
f"codeblock `{sn_name}` in {fpath}:\n"
|
|
292
|
+
f"\n{textwrap.indent(code, prefix=' ')}\n\n"
|
|
293
|
+
f"{traceback.format_exc()}"
|
|
294
|
+
) from err
|
|
270
295
|
return test_block
|
|
271
296
|
|
|
272
297
|
callobj = make_func(sn.code)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-codeblock
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
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>
|
|
@@ -81,7 +81,7 @@ pytest-codeblock
|
|
|
81
81
|
.. _Examples: https://github.com/barseghyanartur/pytest-codeblock/tree/main/examples
|
|
82
82
|
.. _Contributor guidelines: https://pytest-codeblock.readthedocs.io/en/latest/contributor_guidelines.html
|
|
83
83
|
|
|
84
|
-
Test your code blocks.
|
|
84
|
+
Test your documentation code blocks.
|
|
85
85
|
|
|
86
86
|
.. image:: https://img.shields.io/pypi/v/pytest-codeblock.svg
|
|
87
87
|
:target: https://pypi.python.org/pypi/pytest-codeblock
|
|
@@ -266,6 +266,8 @@ Any fenced code block with a recognized Python language tag (e.g., ``python``,
|
|
|
266
266
|
assert result == 9
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
+
----
|
|
270
|
+
|
|
269
271
|
**Grouping example**
|
|
270
272
|
|
|
271
273
|
.. code-block:: markdown
|
|
@@ -280,6 +282,8 @@ Any fenced code block with a recognized Python language tag (e.g., ``python``,
|
|
|
280
282
|
print(x + 1) # Uses x from the first snippet
|
|
281
283
|
```
|
|
282
284
|
|
|
285
|
+
----
|
|
286
|
+
|
|
283
287
|
**pytest marks**
|
|
284
288
|
|
|
285
289
|
.. code-block:: markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{pytest_codeblock-0.1.3 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|