Python: doctest my github-markdown files?

I would like to run the doctrines from this file, and it is not clear to me how to do this:

README.md:

# WELCOME!

This library is helpful and will help you in _many_ ways!

For example:

```
>>> import library
>>> library.helps()
True
```

(aside: can someone help me get this to set aside as a markdown?)

+4
source share
2 answers

As an alternative to doctest, I wrote mkcodes , a script that pulls blocks of code from markdown files so that they can be tested in a separate file.

Here is my actual test script using mkcodes:

mkcodes --github --output tests/docs/test_{name}.py docs
py.test tests
pyflakes tests
pep8 tests
+1
source

You can run docteston READMEthe command line using:

python -m doctest -v README.md

-m Python script. script doctest doctest.testmod . , -v doctest ; , doctest , ( , ).

-1

Source: https://habr.com/ru/post/1537751/


All Articles