Python 禁用了一个使用鼻子的示例测试
有没有办法告诉nose不要测试包含其他需要测试的函数的文件中的特定函数foo()Python 禁用了一个使用鼻子的示例测试,python,nose,doctest,Python,Nose,Doctest,有没有办法告诉nose不要测试包含其他需要测试的函数的文件中的特定函数foo() def foo(): '''Was the function does. :Example: >>> # I don't wan't to test this code >>> # because it uses imports >>> # of some packages not declared as depend
def foo():
'''Was the function does.
:Example:
>>> # I don't wan't to test this code
>>> # because it uses imports
>>> # of some packages not declared as dependencies
'''
最佳您可以提高SkipTest:
from nose.plugins.skip import SkipTest
def test_that_only_works_when_certain_module_is_available():
if module is not available:
raise SkipTest("Test %s is skipped" % func.__name__)
或者使用unittest.skip decorator:
import unittest
@unittest.skip("temporarily disabled")
class MyTestCase(unittest.TestCase):
...
from nose.tools import nottest
@nottest
def test_but_not_really_test()
...
或者,如果这甚至不是测试函数,但被错误地检测为测试函数,并且您不希望该函数在测试报告中显示为跳过的测试,则可以使用nottest decorator标记该函数:
import unittest
@unittest.skip("temporarily disabled")
class MyTestCase(unittest.TestCase):
...
from nose.tools import nottest
@nottest
def test_but_not_really_test()
...
超级的。非常感谢你的帮助。