Dhruv Ghulati
Dhruv Ghulati

Reputation: 3026

pytest not allowing classes with non-static methods

I was following this tutorial for pytest:

http://doc.pytest.org/en/latest/getting-started.html#grouping-multiple-tests-in-a-class

But noticed that if I create:

class ComplexTestClass:
    """
    Complex and more nuanced tests for specific sentences
    """
    def test_multiple_sentences():

If I do not add @staticmethod at the top of the functions, I get an error appearing on the function where it cannot pick up with () is and it gets highlighted in red in my PyCharm.

Is the tutorial (which shows no need for static methods) wrong, or am I wrong and will staticmethod invalidate my tests?

Upvotes: 1

Views: 497

Answers (1)

Billy
Billy

Reputation: 5609

You need the self argument in the method if you're not declaring it a @staticmethod:

def test_multiple_sentences(self):

Upvotes: 3

Related Questions