Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running doctests from Pydev?

Tags:

doctest

pydev

Is there any straightforward way or should I use an external tool like Nose?

like image 324
yanchenko Avatar asked Mar 09 '10 10:03

yanchenko


People also ask

What is the correct way to run all the Doctests?

Right click on a blank space in the python code, and there is a menu option to run all the Doctests found in the file, not just the tests for one function.

What is the correct way to run all Doctests in a given file from the command line?

To run the tests, use doctest as the main program via the -m option to the interpreter. Usually no output is produced while the tests are running, so the example below includes the -v option to make the output more verbose.

Does Pytest run Doctests?

By default, pytest will collect test*. txt files looking for doctest directives, but you can pass additional globs using the --doctest-glob option (multi-allowed).


2 Answers

Pydev 1.6.4 provides support for a nose test runner.

http://pydev.org/manual_adv_pyunit.html describes how to configure the nose test runner.

To run doc tests, you'll need to specify the --with-doctest switch for the nose runner.

like image 167
xverges Avatar answered Sep 16 '22 17:09

xverges


Xv's answer is correct, unless you have tests that are in external files (like testable specifications) in which case you should add the doctest-extension=txt switch (substituting txt for whatever your extension is).

like image 27
Ctrlspc Avatar answered Sep 17 '22 17:09

Ctrlspc