Running examples from Markdown files?

14 views
Skip to first unread message

Skip Montanaro

unread,
Sep 20, 2017, 11:49:22 AM9/20/17
to nose-users
I successfully use Nose to find unit tests and doctests in my Python source. I'd like it to find and run examples in Markdown files as well. I added

doctest-extensions=md

which sorta works, but not quite. I currently have two examples embedded in the file as preformatted text (indented from the left-hand margin). It seems to find only the second, and gets itself confused about indentation. I added

doctest-options=+NORMALIZE_WHITESPACE

which seems to have solved the indentation issue, but it still only finds the second example. If I remove it, it finds the first example. If I add a third example further down the file, it finds that, but not the other two.

Is it possible to have my Nose+Markdown cake and eat it too?

Thx,

Skip Montanaro


Skip Montanaro

unread,
Sep 20, 2017, 12:06:36 PM9/20/17
to nose-users
A bit more sleuthing suggests that it's actually processing all of my examples, but as a single "test". It's not a big deal that it does that, but it would be kinda nice if it treated each chunk of Python examples separated by non-Python text as a separate test.

Skip

Chris Withers

unread,
Sep 28, 2017, 5:58:55 PM9/28/17
to nose-...@googlegroups.com
You could give Sybil a go and see about writing a parser that grabs your
markdown examples and checks them?

http://sybil.readthedocs.io/en/latest/

cheers,

Chris
Reply all
Reply to author
Forward
0 new messages