I'd like to run the doctests from this file, and it's not clear to me out to accomplish it:
README.md
:
# WELCOME!
This library is helpful and will help you in _many_ ways!
For example:
```
>>> import library
>>> library.helps()
True
```
(aside: can anyone help me get this to highlight as markdown?)
You can instruct the Python interpreter to run the doctest module directly from the standard library and pass the file name (s) on the command line: python -m doctest -v example.txt. Because the file name does not end with .py, doctest infers that it must be run with testfile (), not testmod ().
A thing to note: The docstrings ought to be written in restructuredtext (RST). If they are in Markdown, you need to add a mod - see this. The two are similar, but different. For example, a single backquote is required for <code> in Markdown, while two are for RST.
DocTestFailure defines the following attributes: The DocTest object that was being run when the example failed. The Example that failed. The example’s actual output. exception doctest.
MkDocs is a Python package that allows you to build static pages using Markdown. The basic structure of an MkDocs project consists of three main components: You already have your project code ready to go. Create the other two puzzle pieces next using the handy new command provided by MkDocs:
As an alternative to doctest I wrote mkcodes, a script that pulls code blocks out of markdown files so they can be tested in a separate file.
Here's my actual test script using mkcodes:
mkcodes --github --output tests/docs/test_{name}.py docs
py.test tests
pyflakes tests
pep8 tests
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With