Currently, when defining test methods within a class, PyCharm will suggest Method 'test_xyz' may be static, with quick fixes to make a function out of the method, or to convert to a staticmethod.
The issue with converting the method to a function is it removes the method from the class, completely changing the pytest semantics.
The issue with converting to a staticmethod is @staticmethod returns a descriptor, and not the test method itself; this means ordering of decorators is important — e.g. @pytest.mark.usefixtures('stuff') added above@staticmethod does nothing, but works if added below.
Since both of these quick fixes are erroneous or full of pitfalls, it seems wise to suppress the inspection entirely for pytest test methods.
Currently, when defining test methods within a class, PyCharm will suggest
Method 'test_xyz' may be static
, with quick fixes to make a function out of the method, or to convert to a staticmethod.The issue with converting the method to a function is it removes the method from the class, completely changing the pytest semantics.
The issue with converting to a staticmethod is
@staticmethod
returns a descriptor, and not the test method itself; this means ordering of decorators is important — e.g.@pytest.mark.usefixtures('stuff')
added above@staticmethod
does nothing, but works if added below.Since both of these quick fixes are erroneous or full of pitfalls, it seems wise to suppress the inspection entirely for pytest test methods.