Top "Doctest" questions

The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown.

How can I include special characters (tab, newline) in a python doctest result string?

Given the following python script: # dedupe.py import re def dedupe_whitespace(s,spacechars='\t '): """Merge repeated whitespace …

python string special-characters quotes doctest
Python - doctest vs. unittest

I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages …

python unit-testing comparison doctest
Python: using doctests for classes

Is it possible to use Python's doctest concept for classes, not just functions? If so, where shall I put the …

python unit-testing doctest
Custom PyCharm docstring stubs (i.e. for google docstring or numpydoc formats)

Does PyCharm 2.7 (or will PyCharm 3) have support for custom docstring and doctest stubs? If so, how does one go about …

python pycharm docstring doctest sphinx-napoleon
Is there a way to restart or reset the python interpreter within a python doctest?

I am writing a short tutorial, and would like to be able to run the examples therein using python's doctest …

python doctest
How do I run doctests with PyCharm?

In the PyCharm IDE, if I right-click on a function/method with a doctest, sometimes the right-click menu will give …

python intellij-idea pycharm doctest
Can python doctest ignore some output lines?

I'd like to write a doctest like this: """ >>> print a.string() foo : a bar : b date : <…

python doctest
Python doctest with newline characters: inconsistent leading whitespace error

When writing python doctests, how does one properly introduce newline characters within a string in the test? Here's a simple …

python doctest
Python doctest: Skip entire block?

I've got a Python module with docstrings in class methods, and a real-world example in the module docstring. The distinction …

python doctest