0

Unlike instance methods, attempts to ignore a static method directly using @nottest or __test__ = False do not work with nose.

Example with @nottest:

from nose.tools import nottest

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

Example with __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

So how are static methods ignored in nose?

absynce
  • 1,399
  • 16
  • 29

1 Answers1

0

In order to ignore a static method in nose, you must set the decorator or property on the class containing the static method.

Working example with @nottest:

from nose.tools import nottest

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

Working example with __test__ = False:

class TestHelper:
    __test__ = False

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

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

Caveat: this will ignore all methods in the class. As depicted here, use a test helper class.

absynce
  • 1,399
  • 16
  • 29