【发布时间】:2014-10-28 11:24:18
【问题描述】:
我尝试在 py.test 文档测试中使用固定装置。 文档中有getfixture函数,可以直接在doctests中使用。
getfixture('tmpdir')
这按预期工作。
现在我尝试使用在 conftest.py 中定义的我自己的固定装置。 当我运行 py.test --fixtures 时,我看到了我的固定装置。 但是当我尝试在 doctest 中获取我的夹具时,我收到了这条消息。
008 >>> config = getfixture('config')
UNEXPECTED EXCEPTION: FixtureLookupError()
Traceback (most recent call last):
File "/Users/christian/local/lib/python2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest README.txt[2]>", line 1, in <module>
File "/Users/christian/.buildout/eggs/pytest-2.6.1-py2.7.egg/_pytest/python.py", line 1337, in getfuncargvalue
return self._get_active_fixturedef(argname).cached_result[0]
File "/Users/christian/.buildout/eggs/pytest-2.6.1-py2.7.egg/_pytest/python.py", line 1344, in _get_active_fixturedef
fixturedef = self._getnextfixturedef(argname)
File "/Users/christian/.buildout/eggs/pytest-2.6.1-py2.7.egg/_pytest/python.py", line 1202, in _getnextfixturedef
raise FixtureLookupError(argname, self)
FixtureLookupError
知道这里有什么问题。
【问题讨论】: