[TIP] coverage.py with doctest.testfile
jason pellerin
jpellerin at gmail.com
Tue Mar 6 07:15:19 PST 2007
On 3/6/07, David Montgomery <davidlmontgomery at gmail.com> wrote:
> I have coverage.py working with doctest.testmod(), but
> not with doctest.testfile(). The external tests run, but
> coverage.py doesn't pick up the lines executed by the
> text file.
>
> Anyone on the list have experience getting this working?
Doctest coverage works with nose
(http://somethingaboutorange.com/projects/mrl/nose or easy_install
nose).
Example:
foo.py:
def foo():
return 'a'
def bar():
return 'b'
test.txt:
These doctests excercise the 'foo' module.
>>> import foo
>>> foo.foo()
'a'
run:
nosetests -v --with-doctest --doctest-extension=txt --with-coverage
--cover-package=foo
output:
Doctest: test.txt ... ok
Name Stmts Exec Cover Missing
-------------------------------------
foo 4 3 75% 5
----------------------------------------------------------------------
Ran 1 test in 0.053s
JP (nose author)
More information about the testing-in-python
mailing list