nose
패키지는 종종 전용 테스트 파일의 테스트뿐만 아니라 doctests을 실행하는 데 사용됩니다. Doctest 파일에서도 setup
및 teardown
조명기를 실행하려고 시도합니다. 노우즈 실행 설정 사용 안 함
doctesting에 대한 모듈이 다른 목적을 위해 setup
라는 기능을 요구하는 일이
setup
를 호출하고 실패합니다.
File ".../site-packages/nose/suite.py", line 291, in setUp
self.setupContext(ancestor)
File ".../site-packages/nose/suite.py", line 314, in setupContext
try_run(context, names)
File ".../site-packages/nose/util.py", line 468, in try_run
return func(obj)
File "sphinx_ext.py", line 14, in setup
app.connect('build-finished', my_extension)
AttributeError: 'module' object has no attribute 'connect'
(참고 :
def my_tricky_function(arg):
"""Do something testable
>>> my_tricky_function(1)
2
"""
return arg + arg
def my_extension(app):
...
def setup(app):
"""Establish sphinx hooks"""
app.connect('build-finished', my_extension)
가에서 nosestests
결과를 실행 :
명확하게하려면, 여기에 예입니다 setup
는 setup
가 인 범위를 전달 nosetest 인수를 수락 할 때 이 경우 모듈의 이름입니다.
다음 사항은 적용되지 않습니다.
__test__ = False
(또는 this decorator을 사용)을setup
에 추가해도 호출이 중지되지 않습니다.- 은 모듈 수준 설정을 중지하지 않습니다
my_tricky_function.setup = None
설정--ignore-files
- 나는 다음과 같은 다소 해키 솔루션을 발견
어둠 속에서 그냥 쐈다. 'my_tricky_function.setup = None' 설정이 도움이 되었습니까? – alecxe