This file (project.md) has some example code and session blocks including a Python doctest directive example.
Note no <BLANKLINE>
directive in the output block of a Python
code block output block pair.
def greeting(name: str) -> str:
return "Hello" + "\n\n" + name
print(greeting("World!"))
Here is the output it produces.
Hello
World!
A second FCB that calls the function greeting() defined in the first FCB.
text = greeting("Planet!")
text = text.replace("\n\n", " ")
assert text == "Hello Planet!" # this assert is in the Markdown example.
Blank lines in the expected output must be replaced with <BLANKLINE>
.
To see un-rendered Markdown navigate to tests/md/project.md on GitHub
and press the Code
button.
>>> print("Hello\n\nWorld!")
Hello
<BLANKLINE>
World!
Here is an interactive Python session showing an
expected exception and use of the doctest directive
IGNORE_EXCEPTION_DETAIL
.
To see the doctest directive navigate to [project.md unrendered][1].
>>> int("def") #doctest:+IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError:
>>> coffee = 5
>>> coding = 5
>>> enjoyment = 10
>>> print(coffee + coding)
10
>>> coffee + coding == enjoyment
True