基本上在项目中我使用以下模式:
package:
__init__.py
_mod1.py
_mod2.py
这些模块被认为是实现细节,我不希望用户导入它们。我使用doctests来测试那些内部模块。在默认配置中,nosetests在这些模块中找不到doctests。
我尝试使用match
选项修复它(并匹配doctest模块),但我从python stdlib获得虚拟匹配。
系统详情:
这是我的鼻子配置文件:
[nosetests]
match=[^.][Tt]est
with-doctest=1
processes=50
process-timeout=25
verbosity=3
attr=!singleprocess
ignore-files=.*pythonz.*
伪造比赛的例子:
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Decorator to mark a function or method as a test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/util.py", line 613, in newfunc
return func(*arg, **kw)
TypeError: istest() missing 1 required positional argument: 'func'
======================================================================
ERROR: Decorator to mark a function or method as *not* a test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/util.py", line 613, in newfunc
return func(*arg, **kw)
TypeError: nottest() missing 1 required positional argument: 'func'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Decorator to mark a function or method as a test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/util.py", line 613, in newfunc
return func(*arg, **kw)
TypeError: istest() missing 1 required positional argument: 'func'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Decorator to mark a function or method as a test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/util.py", line 613, in newfunc
return func(*arg, **kw)
TypeError: istest() missing 1 required positional argument: 'func'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Decorator to mark a function or method as a test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/jb/.virtualenvs/silf-backend-commons/lib/python3.3/site-packages/nose/util.py", line 613, in newfunc
return func(*arg, **kw)
TypeError: istest() missing 1 required positional argument: 'func'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
nose.proxy.TypeError: skipTest() missing 1 required positional argument: 'reason'
-------------------- >> begin captured logging << --------------------
root: DEBUG: Firing event <EventObject power_up, (*('default',), **{})>
root: DEBUG: Firing event <EventObject tick, (*(), **{})>
--------------------- >> end captured logging << ---------------------
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
nose.proxy.TypeError: skipTest() missing 1 required positional argument: 'reason'
-------------------- >> begin captured logging << --------------------
Test: INFO: Initializing experiment
Test: INFO: Initialized client
Test: INFO: Initialized manager
Test: INFO: Started main thread
--------------------- >> end captured logging << ---------------------
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
======================================================================
ERROR: Skip this test.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jb/.pythonz/pythons/CPython-3.3.2/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
function()
TypeError: skipTest() missing 1 required positional argument: 'reason'
----------------------------------------------------------------------
答案 0 :(得分:1)
如果您只想阻止导入,可以使用module.doctest(例如)命名您的doctests,并使用--doctest-extension = doctest。这种方法可能是最好的做法。
如果 需要使用下划线开始模块名称,则需要替换nose的默认忽略规则,该规则明确排除以您命名的方式命名的文件。例如,如果您将以下内容添加到配置中,则会发现您的doctests:
ignore-files=DONTIGNOREANYFILES