File tree Expand file tree Collapse file tree 4 files changed +16
-0
lines changed
Expand file tree Collapse file tree 4 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ Michael Droettboom
118118Michael Seifert
119119Michal Wajszczuk
120120Mike Lundy
121+ Nathaniel Waisbrot
121122Ned Batchelder
122123Neven Mundar
123124Nicolas Delaby
Original file line number Diff line number Diff line change @@ -271,6 +271,8 @@ def classnamefilter(self, name):
271271 return self ._matches_prefix_or_glob_option ('python_classes' , name )
272272
273273 def istestfunction (self , obj , name ):
274+ if isinstance (obj , staticmethod ):
275+ obj = obj .__func__
274276 return (
275277 (self .funcnamefilter (name ) or self .isnosetest (obj )) and
276278 safe_getattr (obj , "__call__" , False ) and fixtures .getfixturemarker (obj ) is None
Original file line number Diff line number Diff line change 1+ Allow class methods decorated as ``@staticmethod`` to be candidates for collection as a test function.
Original file line number Diff line number Diff line change @@ -143,6 +143,18 @@ class test(object):
143143 "*collected 0*" ,
144144 ])
145145
146+ def test_static_method (self , testdir ):
147+ testdir .getmodulecol ("""
148+ class Test(object):
149+ @staticmethod
150+ def test_something():
151+ pass
152+ """ )
153+ result = testdir .runpytest ()
154+ result .stdout .fnmatch_lines ([
155+ "*collected 1*" ,
156+ ])
157+
146158 def test_setup_teardown_class_as_classmethod (self , testdir ):
147159 testdir .makepyfile (test_mod1 = """
148160 class TestClassMethod(object):
You can’t perform that action at this time.
0 commit comments