你如何忽略鼻子中的静态方法(nosetests)?

问题描述 投票:0回答:1

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

那么如何在鼻子中忽略静态方法呢?

python nose
1个回答
0
投票

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

@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

警告:这将忽略类中的所有方法。如此处所示,使用测试帮助程序类。

© www.soinside.com 2019 - 2024. All rights reserved.