pytest-codeblock 0.5.7__tar.gz → 0.5.9__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.
Files changed (25) hide show
  1. {pytest_codeblock-0.5.7/src/pytest_codeblock.egg-info → pytest_codeblock-0.5.9}/PKG-INFO +2 -2
  2. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/pyproject.toml +10 -3
  3. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/__init__.py +1 -1
  4. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/md.py +15 -2
  5. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/rst.py +15 -2
  6. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9/src/pytest_codeblock.egg-info}/PKG-INFO +2 -2
  7. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock.egg-info/requires.txt +1 -1
  8. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/LICENSE +0 -0
  9. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/README.rst +0 -0
  10. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/setup.cfg +0 -0
  11. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/collector.py +0 -0
  12. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/config.py +0 -0
  13. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/constants.py +0 -0
  14. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/helpers.py +0 -0
  15. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/pytestrun.py +0 -0
  16. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/tests/__init__.py +0 -0
  17. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/tests/test_customisation.py +0 -0
  18. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/tests/test_integration.py +0 -0
  19. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/tests/test_nameless_codeblocks.py +0 -0
  20. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/tests/test_pytest_codeblock.py +0 -0
  21. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock/tests/test_pytestrun_marker.py +0 -0
  22. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock.egg-info/SOURCES.txt +0 -0
  23. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock.egg-info/dependency_links.txt +0 -0
  24. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/src/pytest_codeblock.egg-info/entry_points.txt +0 -0
  25. {pytest_codeblock-0.5.7 → pytest_codeblock-0.5.9}/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.7
3
+ Version: 0.5.9
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>
@@ -41,13 +41,13 @@ Requires-Dist: twine; extra == "dev"
41
41
  Requires-Dist: uv; extra == "dev"
42
42
  Provides-Extra: test
43
43
  Requires-Dist: django; extra == "test"
44
- Requires-Dist: fake.py; extra == "test"
45
44
  Requires-Dist: moto[s3]; extra == "test"
46
45
  Requires-Dist: openai; extra == "test"
47
46
  Requires-Dist: pytest; extra == "test"
48
47
  Requires-Dist: pytest-cov; extra == "test"
49
48
  Requires-Dist: pytest-django; extra == "test"
50
49
  Requires-Dist: respx; extra == "test"
50
+ Requires-Dist: langchain-tests; extra == "test"
51
51
  Provides-Extra: docs
52
52
  Requires-Dist: sphinx; extra == "docs"
53
53
  Requires-Dist: sphinx-autobuild; extra == "docs"
@@ -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.7"
5
+ version = "0.5.9"
6
6
  requires-python = ">=3.10"
7
7
  dependencies = [
8
8
  "pytest",
@@ -59,13 +59,13 @@ dev = [
59
59
  ]
60
60
  test = [
61
61
  "django",
62
- "fake.py",
63
62
  "moto[s3]",
64
63
  "openai",
65
64
  "pytest",
66
65
  "pytest-cov",
67
66
  "pytest-django",
68
67
  "respx",
68
+ "langchain-tests", # Module-scoped fixtures for testing scope resolution
69
69
  ]
70
70
  docs = [
71
71
  "sphinx",
@@ -150,6 +150,7 @@ target-version = "py39"
150
150
 
151
151
  [tool.ruff.lint.per-file-ignores]
152
152
  "conftest.py" = ["PERF203"]
153
+ "src/fake.py" = ["INP001"]
153
154
 
154
155
  [tool.ruff.lint.isort]
155
156
  known-first-party = ["pytest_codeblock"]
@@ -223,7 +224,7 @@ ignore_missing_imports = true
223
224
 
224
225
  [tool.pydoclint]
225
226
  style = "sphinx"
226
- exclude = "\\.git|\\.tox|tests/data|\\.venv"
227
+ exclude = "\\.git|\\.tox|tests/data|\\.venv|fake"
227
228
  require-return-section-when-returning-nothing = false
228
229
  allow-init-docstring = true
229
230
  arg-type-hints-in-docstring = false
@@ -253,6 +254,7 @@ ignore = [
253
254
  ".idea",
254
255
  ".vscode",
255
256
  ".DS_Store",
257
+ ".claude",
256
258
  "Thumbs.db",
257
259
  ".ruff_cache",
258
260
  ".coverage.*",
@@ -267,6 +269,7 @@ ignore = [
267
269
  "docs/_implement_pytest_hooks.rst",
268
270
  "docs/changelog.rst",
269
271
  "docs/code_of_conduct.rst",
272
+ "docs/contributor_guidelines.rst",
270
273
  "docs/documentation.rst",
271
274
  "docs/full-llms.rst",
272
275
  "docs/index.rst",
@@ -277,6 +280,7 @@ ignore = [
277
280
  "docs/source_tree_full.rst",
278
281
  "docs/make.bat",
279
282
  "docs/Makefile",
283
+ "src/pytest_codeblock/tests/pytest_codeblock_*.py",
280
284
  ]
281
285
  order = [
282
286
  "README.rst",
@@ -320,6 +324,7 @@ ignore = [
320
324
  ".idea",
321
325
  ".vscode",
322
326
  ".DS_Store",
327
+ ".claude",
323
328
  "Thumbs.db",
324
329
  ".ruff_cache",
325
330
  ".coverage.*",
@@ -334,6 +339,7 @@ ignore = [
334
339
  "docs/_implement_pytest_hooks.rst",
335
340
  "docs/changelog.rst",
336
341
  "docs/code_of_conduct.rst",
342
+ "docs/contributor_guidelines.rst",
337
343
  "docs/documentation.rst",
338
344
  "docs/full-llms.rst",
339
345
  "docs/index.rst",
@@ -345,4 +351,5 @@ ignore = [
345
351
  "docs/make.bat",
346
352
  "docs/Makefile",
347
353
  "examples",
354
+ "src/pytest_codeblock/tests/pytest_codeblock_*.py",
348
355
  ]
@@ -6,7 +6,7 @@ from .md import MarkdownFile
6
6
  from .rst import RSTFile
7
7
 
8
8
  __title__ = "pytest-codeblock"
9
- __version__ = "0.5.7"
9
+ __version__ = "0.5.9"
10
10
  __author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
11
11
  __copyright__ = "2025-2026 Artur Barseghyan"
12
12
  __license__ = "MIT"
@@ -3,6 +3,8 @@ import inspect
3
3
  import re
4
4
  import textwrap
5
5
  import traceback
6
+ import types
7
+ from collections.abc import Generator
6
8
  from typing import Optional
7
9
 
8
10
  import pytest
@@ -157,12 +159,23 @@ def parse_markdown(text: str) -> list[CodeSnippet]:
157
159
  return snippets
158
160
 
159
161
 
160
- class MarkdownFile(pytest.File):
162
+ class MarkdownFile(pytest.Module):
161
163
  """
162
164
  Collector for Markdown files, extracting only `test_`-prefixed code
163
165
  snippets.
164
166
  """
165
- def collect(self):
167
+
168
+ def _getobj(self) -> types.ModuleType:
169
+ m = types.ModuleType(self.path.stem)
170
+ m.__file__ = str(self.path)
171
+ m.__test__ = False # prevent PyCollector from auto-collecting
172
+ return m
173
+
174
+ def collect(self) -> Generator[pytest.Function, None, None]:
175
+ # Register with fixture manager so module-scoped fixtures can find
176
+ # a pytest.Module parent node (fixes scope resolution when plugins
177
+ # like pytest-recording/langchain-tests define module-scoped fixtures).
178
+ self.session._fixturemanager.parsefactories(self)
166
179
  text = self.path.read_text(encoding="utf-8")
167
180
  raw = parse_markdown(text)
168
181
  config = get_config()
@@ -3,6 +3,8 @@ import inspect
3
3
  import re
4
4
  import textwrap
5
5
  import traceback
6
+ import types
7
+ from collections.abc import Generator
6
8
  from pathlib import Path
7
9
  from typing import Optional, Union
8
10
 
@@ -286,9 +288,20 @@ def parse_rst(text: str, base_dir: Path) -> list[CodeSnippet]:
286
288
  return snippets
287
289
 
288
290
 
289
- class RSTFile(pytest.File):
291
+ class RSTFile(pytest.Module):
290
292
  """Collect RST code-block tests as real test functions."""
291
- def collect(self):
293
+
294
+ def _getobj(self) -> types.ModuleType:
295
+ m = types.ModuleType(self.path.stem)
296
+ m.__file__ = str(self.path)
297
+ m.__test__ = False # prevent PyCollector from auto-collecting
298
+ return m
299
+
300
+ def collect(self) -> Generator[pytest.Function, None, None]:
301
+ # Register this node with the fixture manager so that module-scoped
302
+ # fixtures (e.g. vcr_cassette_dir from pytest-recording/langchain-tests)
303
+ # can resolve their scope by walking up to a pytest.Module parent.
304
+ self.session._fixturemanager.parsefactories(self)
292
305
  text = self.path.read_text(encoding="utf-8")
293
306
  raw = parse_rst(text, self.path)
294
307
  config = get_config()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-codeblock
3
- Version: 0.5.7
3
+ Version: 0.5.9
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>
@@ -41,13 +41,13 @@ Requires-Dist: twine; extra == "dev"
41
41
  Requires-Dist: uv; extra == "dev"
42
42
  Provides-Extra: test
43
43
  Requires-Dist: django; extra == "test"
44
- Requires-Dist: fake.py; extra == "test"
45
44
  Requires-Dist: moto[s3]; extra == "test"
46
45
  Requires-Dist: openai; extra == "test"
47
46
  Requires-Dist: pytest; extra == "test"
48
47
  Requires-Dist: pytest-cov; extra == "test"
49
48
  Requires-Dist: pytest-django; extra == "test"
50
49
  Requires-Dist: respx; extra == "test"
50
+ Requires-Dist: langchain-tests; extra == "test"
51
51
  Provides-Extra: docs
52
52
  Requires-Dist: sphinx; extra == "docs"
53
53
  Requires-Dist: sphinx-autobuild; extra == "docs"
@@ -31,10 +31,10 @@ sphinx-source-tree
31
31
 
32
32
  [test]
33
33
  django
34
- fake.py
35
34
  moto[s3]
36
35
  openai
37
36
  pytest
38
37
  pytest-cov
39
38
  pytest-django
40
39
  respx
40
+ langchain-tests