-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doctest should ignore lines starting with ``` when run on Markdown files #7374
Comments
I think it actually makes a lot of sense to do this in pytest rather than upstream; in particular we can ensure that the logic only applies to markdown files (e.g. |
Is there a bpo bug for the upstream problem? I'd be a little concerned just blindly removing a trailing triple-tick for example it would break this test: >>> my_object = MyObject()
>>> my_object
```my
repr
is fancy
``` |
I never opened an upstream bug.
If this is a concern one could modify the doctest matcher to try to determine in a more sophisticated way if the example block is in a code fence. |
let's start with an upstream bug report before we decide to diverge |
I'm sorry, but I'm not interested in trying to push a change into CPython itself. If you want to do it, feel free. Libraries like pytest can move much faster than the standard library, so it makes sense to make changes like this in them first, then backport them into the upstream later if that becomes feasible. It doesn't make sense to block movement on an issue like this on something happening in the extremely slow moving standard library. |
pytest has dedicated doctest maintainer - perhaps doctestplus is interested in providing the feature |
When you use
--doctest-glob=*.md
to run doctests on Markdown files, you often run into issues doctesting code blocks likeYou get errors like
The problem is that it thinks the closing
```
is part of the doctest. This is really a problem with the upstream doctest, but getting a fix like this included in it seems much harder than fixing pytest.A workaround here is to always add an empty line before the closing
```
. But aside from being annoying to do, this affects the rendering of the document with some (all?) Markdown processors, adding an empty line to the end of the rendered codeblock.When using the base doctest, you can fix this with something like
Presumably a similar fix could be made in pytest when testing Markdown files, so that it works better.
The text was updated successfully, but these errors were encountered: