Reputation: 17767
I have a project with a structure like that :
my_project_with_tests/
project/
__init__.py
module.py
test/
test.py
module.py
contains two doctest
'ed functions:
def foo():
"""
>>> foo()
1
"""
return 1
def test_foo_doctest():
"""
>>> module.foo()
1
"""
pass
def bar():
"""
>>> bar()
"""
return 1
test.py
contains the necessary bits to run tests:
import sys
import os.path
sys.path = [os.path.abspath("../project")] + sys.path
import module
def test_foo():
assert module.foo() == 1
def test_bar():
assert module.bar() == 1
I'm currently running my tests using nose
with
nosetests \
--all-modules \
--traverse-namespace \
--with-coverage \
--cover-tests \
--with-doctest \
--where test/
However, it does not run doctests
from my project
sources directory (but doctests
from the test directory are ok, since test_foo_doctest
passes).
nose
?doctests
from the project
directory
nose
project
directoryUpvotes: 4
Views: 1430
Reputation: 12983
That's a good way to call nose, but there's a small problem that prevents your doctests from running. See #2
Change --where test/
to --where .
assuming you run the command from project/project
. That way nose will see the doctests. Right now it's only looking in test/
Upvotes: 2