pytest-codeblocks
pytest-codeblocks copied to clipboard
Suport for interactive Python shell code?
It is quite often markdown contains interactive Python shell code like:
>>> print("Hello World!")
Hello World!
>>> def add(a, b):
... return a + b
...
>>> add(2,3)
5
Currently, I got following exception for these blocks in my README.md.
invalid syntax (<string>, line 1)
Can you add support to test it? I expect the behaviour to be same as pytest --doctest-modules, as if the code block is a function's doc-string.
Interesting idea! I don't have any spare time to devote to this right now, but you can either submit a PR or sponsor me so I can move this into my working hours.
I came here looking for this too, I just thought it worth mentioning that Github supports syntax highlighting of interactive codeblocks with a different code than normal Python, pycon, e.g.:
```pycon
>>> "Hello " + "stranger"
'Hello stranger'
```
Renders as:
>>> "Hello " + "stranger"
'Hello stranger'