MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_static_method

Method test_static_method

testing/python/collect.py:188–208  ·  view source on GitHub ↗

Support for collecting staticmethod tests (#2528, #2699)

(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

186 result.stdout.fnmatch_lines(["*collected 0*"])
187
188 def test_static_method(self, pytester: Pytester) -> None:
189 """Support for collecting staticmethod tests (#2528, #2699)"""
190 pytester.getmodulecol(
191 """
192 import pytest
193 class Test(object):
194 @staticmethod
195 def test_something():
196 pass
197
198 @pytest.fixture
199 def fix(self):
200 return 1
201
202 @staticmethod
203 def test_fix(fix):
204 assert fix == 1
205 """
206 )
207 result = pytester.runpytest()
208 result.stdout.fnmatch_lines(["*collected 2 items*", "*2 passed in*"])
209
210 def test_setup_teardown_class_as_classmethod(self, pytester: Pytester) -> None:
211 pytester.makepyfile(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
getmodulecolMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected