Skip to content

Commit

Permalink
Release 0.5.0
Browse files Browse the repository at this point in the history
* Add support for pytest 8
* Drop support for pytest 6
* Fix critical bug allowing syntax errors to pass tests
  • Loading branch information
freider committed Feb 7, 2024
1 parent 8fdb936 commit 727e06d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ Or for fun, you can use this plugin to include testing of the validity of snippe
```

## Known issues

* Tested with pytest 6 and 7. There is a minor incompatibility with pytest 8.
* Code for docstring-inlined test discovery can probably be done better (similar to how doctest does it). Currently, seems to sometimes traverse into Python's standard library which isn't great...
* Traceback logic is extremely hacky, wouldn't be surprised if the tracebacks look weird sometimes
* Line numbers are "wrong" for docstring-inlined snippets (since we don't know where in the file the docstring starts)
* Line numbers are "wrong" for continuation blocks even in pure markdown files (can be worked out with some refactoring)
* There are probably more appropriate ways to use pytest internal APIs to get more features "for free" - current state of the code is a bit "patch it til' it works".
* Assertions are not rewritten w/ pretty data structure inspection like they are with regular pytest tests by default
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-markdown-docs"
version = "0.4.3"
version = "0.5.0"
description = "Run markdown code fences through pytest"
readme = "README.md"
authors = ["Modal Labs", "Elias Freider <elias@modal.com>"]
Expand All @@ -12,6 +12,7 @@ include = ["LICENSE"]
[tool.poetry.dependencies]
python = "^3.8"
markdown-it-py = ">=2.2.0, <4.0"
pytest = ">=7.0.0"

[tool.poetry.plugins]

Expand Down
19 changes: 17 additions & 2 deletions tests/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,27 @@ def pytest_markdown_docs_globals():
```
""",
)

# run all tests with pytest
result = testdir.runpytest("--markdown-docs")
result.assert_outcomes(passed=1, failed=2)


def test_continuation(testdir):
testdir.makefile(
".md",
"""
```python
b = "hello"
```
```python continuation
assert b + " world" == "hello world"
```
""",
)
result = testdir.runpytest("--markdown-docs")
result.assert_outcomes(passed=2)


def test_traceback(testdir):
testdir.makefile(
".md",
Expand Down

0 comments on commit 727e06d

Please sign in to comment.