我有一个结构像这样的项目:
my_project_with_tests/
project/
__init__.py
module.py
test/
test.py
module.py包含两个doctest'ed 函数:
def foo():
"""
>>> foo()
1
"""
return 1
def test_foo_doctest():
"""
>>> module.foo()
1
"""
pass
def bar():
"""
>>> bar()
"""
return 1
test.py包含运行测试所需的位:
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
我目前正在使用nosewith运行我的测试
nosetests \
--all-modules \
--traverse-namespace \
--with-coverage \
--cover-tests \
--with-doctest \
--where test/
但是,它不会doctests从我的project源目录运行(但从doctests测试目录运行是可以的,因为test_foo_doctest通过了)。
- 这是打电话的好方法
nose吗? - 如何
doctests从project目录 运行- 使用
nose - 不改变目录结构
- 没有在
project目录中运行测试
- 使用