Class methods can now be discovered as tests (#10552)

Fix #10525
This commit is contained in:
Marko Pacak
2022-12-02 16:53:04 +01:00
committed by GitHub
parent eca93db05b
commit 9fbd67dd4b
6 changed files with 24 additions and 8 deletions

View File

@@ -403,8 +403,8 @@ class PyCollector(PyobjMixin, nodes.Collector):
def istestfunction(self, obj: object, name: str) -> bool:
if self.funcnamefilter(name) or self.isnosetest(obj):
if isinstance(obj, staticmethod):
# staticmethods need to be unwrapped.
if isinstance(obj, (staticmethod, classmethod)):
# staticmethods and classmethods need to be unwrapped.
obj = safe_getattr(obj, "__func__", False)
return callable(obj) and fixtures.getfixturemarker(obj) is None
else: