pytest-codeblock 0.1.4__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.4/pytest_codeblock.egg-info → pytest_codeblock-0.1.5}/PKG-INFO +2 -2
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/README.rst +1 -1
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pyproject.toml +1 -1
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock/__init__.py +1 -1
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock/rst.py +28 -4
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5/pytest_codeblock.egg-info}/PKG-INFO +2 -2
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/LICENSE +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock/collector.py +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock/constants.py +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock/md.py +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/SOURCES.txt +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/dependency_links.txt +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/entry_points.txt +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/requires.txt +0 -0
- {pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/top_level.txt +0 -0
- {pytest_codeblock-0.1.4 → 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
|
|
@@ -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
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pytest-codeblock"
|
|
3
|
-
version = "0.1.4"
|
|
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
|
|
|
@@ -257,17 +259,39 @@ class RSTFile(pytest.File):
|
|
|
257
259
|
combined = group_snippets(tests)
|
|
258
260
|
|
|
259
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
|
+
|
|
260
266
|
# Create a Python function for this snippet
|
|
261
267
|
if DJANGO_DB_MARKS.intersection(sn.marks):
|
|
262
268
|
# Function *requests* the db fixture
|
|
263
|
-
def make_func(code):
|
|
269
|
+
def make_func(code, sn_name=_sn_name, fpath=_fpath):
|
|
264
270
|
def test_block(db):
|
|
265
|
-
|
|
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
|
|
266
281
|
return test_block
|
|
267
282
|
else:
|
|
268
|
-
def make_func(code):
|
|
283
|
+
def make_func(code, sn_name=_sn_name, fpath=_fpath):
|
|
269
284
|
def test_block():
|
|
270
|
-
|
|
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
|
|
271
295
|
return test_block
|
|
272
296
|
|
|
273
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_codeblock-0.1.4 → pytest_codeblock-0.1.5}/pytest_codeblock.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{pytest_codeblock-0.1.4 → 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
|