您如何忽略鼻子(鼻孔)的静态方法?

时间:2019-03-05 23:50:55

标签: python nose

instance methods不同,尝试使用@nottest__test__ = False直接忽略静态方法 不适用于鼻子。

@nottest的示例:

from nose.tools import nottest

class TestHelper:
    @nottest
    @staticmethod
    def test_my_sample_test_helper()
        #code here ...

__test__ = False的示例:

class TestHelper:
    @staticmethod
    def test_my_sample_test_helper()
        __test__ = False
        #code here ...

    # Or it could normally be set here.
    # test_my_sample_test_helper.__test__ = False

那么鼻子中的静态方法如何被忽略?

1 个答案:

答案 0 :(得分:0)

为了忽略鼻子中的静态方法,必须在包含静态方法的类上设置装饰器或属性

使用@nottest的工作示例:

from nose.tools import nottest

@nottest
class TestHelper:
    @staticmethod
    def test_my_sample_test_helper()
        #code here ...

使用__test__ = False的工作示例:

class TestHelper:
    __test__ = False

    @staticmethod
    def test_my_sample_test_helper()
        #code here ...

# Or it can be set here.
# TestHelper.__test__ = False

注意事项::这将忽略类中的所有方法。如此处所示,使用测试助手类。

相关问题