Comments (5)
I would not say that Markdown is not supported, it is. I use Markdown and doctests in multiple projects. Here's just one example: https://github.com/wemake-services/inspect313
But, yes. You have to keep in mind that triple backticks are treated as an output. So, you have to add an empty line before the backticks: https://github.com/wemake-services/inspect313/blob/1ed3f77059199aa17db4be0fe713315bda87d101/README.md#L46-L48
from cpython.
Yes, you can workaround by adding a blank line at the end but that adds an easy source of error, looks ugly in the code and I've run into cases where the block gets rendered with blank line. Sorry, I didn't include this point in the original description - I felt it was already quite long for such a small change.
from cpython.
There are also downstream issues in pytest (pytest-dev/pytest#7374) and pytest-doctestplus (scientific-python/pytest-doctestplus#221). This behaviour is inherited by those libraries as well since they depend on the stdlib doctest module for collecting the doctest fragments. The SymPy in-house doctest runner removes these (https://github.com/sympy/sympy/blob/d91b8ad6d36a59a879cc70e5f4b379da5fdd46ce/sympy/testing/runtests.py#L1827-L1831).
It looks like doctest was not designed for markdown files. It doesn't know anything about markdown backticks and just uses a regex starting with PS1 and ending with either PS1 or a blank line:
Lines 608 to 624 in 027fa2e
from cpython.
It looks like this is worthy of a discussion, as it's clearly not something that will "just be OK" but may be of use to the community nonetheless. I'll open one in the morning when I have sufficient time at the keyboard.
@oscarbenjamin - what do you think of the proposed change to adjust the regex to:
_EXAMPLE_RE = re.compile(r'''
# Source consists of a PS1 line followed by zero or more PS2 lines.
(?P<source>
(?:^(?P<indent> [ ]*) >>> .*) # PS1 line
(?:\n [ ]* \.\.\. .*)*) # PS2 lines
\n?
# Want consists of any non-blank lines that do not start with PS1.
(?P<want> (?:(?![ ]*$) # Not a blank line
(?![ ]*```) # Not end of a code block
(?![ ]*>>>) # Not a line starting with PS1
.+$\n? # But any other line
)*)
''', re.MULTILINE | re.VERBOSE)
from cpython.
what do you think of the proposed change to adjust the regex to:
The obvious failure case would be if the test output includes triple backticks. That doesn't seem like a big deal to me but I might be wrong.
I imagine that this is best handled outside of the stdlib in the first instance though. See scientific-python/pytest-doctestplus#247.
from cpython.
Related Issues (20)
- Setting the line number is ignored in `INSTRUMENTED_YIELD_VALUE`
- Missing PyDECREF calls for ADDITEMS opcode of _pickle.c HOT 1
- riscv64: Python/perf_jit_trampoline.c:491:6: error: #error "Unsupported target architecture" HOT 2
- Support copy.replace() on AST nodes HOT 6
- Mac M1: ctypes crashes Blender application when I load and run my dylib. HOT 6
- 'And' functionality between lists HOT 4
- Specialization for accurate complex summation in sum()? HOT 9
- argparse: usage text of arguments in mutually exclusive groups no longer wraps in Python 3.13
- Incorrect use of _PyLong_CompactValue() HOT 1
- subprocess.run timeout does not function if shell=True and capture_output=True HOT 2
- `readline.set_history_length` corrupts history files when used in a libedit build HOT 11
- Consider support "all" as an valid action for ``warnings.filterswarnings/simplefilter``. HOT 1
- Use `do-while(0)` to protect `ADJUST_INDICES` macro
- wrong number sorting HOT 4
- Wrong extract version set in local headers for files located beyond zip64 limit HOT 4
- LZMA filtering documentation very poor
- Test suite interrupted by xml.etree.ElementTree.ParseError: not well-formed (invalid token) HOT 8
- Support `allow_nan` for `json.load[s]()` for JSON compliance HOT 1
- Different output from importlib.resources.files() in REPL in 3.12 versus 3.13 HOT 2
- Add fast path to `deepcopy()` for empty list/tuple/dict/set HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.