Conversation
64acbfc to
bd40745
Compare
|
@Thisch If you check out the PR, do Do the example commands above work? e.g. You can also try putting errors into examples/ and running them. |
794bf0d to
0c45c84
Compare
|
Hi! Thx a lot for putting so much work into this! Let me first try to test your included edit: So here are my first results (Forgive me if you have already mentioned the differences somewhere):
@tony which library supports parsing the |
| raise RuntimeError | ||
|
|
||
| .. testoutput:: | ||
| .. docutils:: |
There was a problem hiding this comment.
I guess this should be .. doctest::, right?
| NOT EVALUATED | ||
|
|
||
| .. testoutput:: | ||
| .. docutils:: |
| .. testcode:: | ||
|
|
||
| {} | ||
| .. docutils:: |
|
@Thisch in re: your tests here Can you do
In regards to this QA list when you are testing, can you show me when it errors / how it errors / etc? For me |
|
@tony Sry that my comment wasn't clear enough. What I did in my tests was just to test your examples (rst and markdown files in The reason why I did that is that I wanted to see what is already supported by pytest and what isn't. |
The The directive is a compromise for not fully supported sphinx.ext.doctest, but it's nice because it helps support some sphinx users (as long as its not using options) For context, docutils itself, only the raw node is, e.g. >>> 4 + 4 |
Okay, so this was added because both |
e577471 to
1f7d270
Compare
1f7d270 to
fe095c4
Compare
pip install "rst-to-myst[sphinx]" rst2myst convert using_the_shapereader.rst See also: - https://rst-to-myst.readthedocs.io/en/latest/
Editable: pip install -e .[myst-parser] zsh: pip install -e ".[myst-parser]" pip install pytest-sphinx[myst-parser] zsh: pip install "pytest-sphinx[myst-parser]"
…ide) python -m doctest_docutils examples/test.rst python -m doctest_docutils examples/test.md Multiple files: python -m doctest_docutils examples/test.rst examples/test.md Show results: python -m doctest_docutils examples/test.rst examples/test.md -v Verbose logging: python -m doctest_docutils examples/test.rst -v --log-level DEBUG With entr(1), requires separate installation: ls *.py examples/*.* tests/*.py | entr -s 'python -m doctest_docutils examples/test.rst examples/test.md -v' Caveats: Only supports raw doctest_blocks and doctest directives. No support for testcode / testoutput / testsetup / testcleanup: testcode and testoutput in particular: - add much more complexity - requiring overriding of multiple methods - aren't standard doctest (sphinx.ext.doctest uses them) - aren't adopted nearly as often as doctest itself
- Uses docutils instead of regular expressions to parse - Requires docutils - Supports markdown - Requires myst-parser package - pytest can be invoked on .md files - Removes support for testcode and testoutput - Removes requirement for sphinx-doc Example usage: pytest examples/ ==== test session starts ===== platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0 rootdir: ~/python/pytest-sphinx plugins: sphinx-0.4.0 collected 9 items examples/test.md ... [ 33%] examples/test.rst .... [ 77%] examples/test.txt .. [100%] ===== 9 passed in 0.10s ====== Also: - Defer .py, .txt to normal pytest.doctest
fe095c4 to
4da1f31
Compare
Implements #37
What's incomplete
What's supported
reStructuredText: Pure docutils parsing
Markdown: via myst-parser (github) + docutils
docutils' style doctest blocks
docutils.nodes.doctest_block: docutils documentation, on pydoc.dev.. doctest [group]blocks with no optionsreStructuredText:
markdown:
What's removed
sphinx.ext.doctest's support for:.. testsetup:: [group].. testcleanup:: [group].. testcode:: [group].. testoutput:: [group]Options for
.. doctest:: [group]: These could potentially be added backRequirements
$ pip install docutils myst-parserTest rerunning
Doctest: install
entr(1)Pytest: install
pytest-watcher$ pip install pytest-watcherdoctestmoduleNormal runs
Per doctest, these are silent unless an error is detected:
reStructuredText:
Markdown:
Multiple files:
-v: Show resultsThese will output even if there's no error
Verbose logging
Retry on file save
via
entr(1), requires separate installation:pytest
$ pytest examples/Output:
Verbose
$ pytest examples/test.rst -vOutput: