MCPcopy
hub / github.com/pytest-dev/pytest / pytest_pycollect_makeitem

Function pytest_pycollect_makeitem

src/_pytest/unittest.py:59–76  ·  view source on GitHub ↗
(
    collector: Module | Class, name: str, obj: object
)

Source from the content-addressed store, hash-verified

57
58
59def pytest_pycollect_makeitem(
60 collector: Module | Class, name: str, obj: object
61) -> UnitTestCase | None:
62 try:
63 # Has unittest been imported?
64 ut = sys.modules["unittest"]
65 # Is obj a subclass of unittest.TestCase?
66 # Type ignored because `ut` is an opaque module.
67 if not issubclass(obj, ut.TestCase): # type: ignore
68 return None
69 except Exception:
70 return None
71 # Is obj a concrete class?
72 # Abstract classes can't be instantiated so no point collecting them.
73 if inspect.isabstract(obj):
74 return None
75 # Yes, so let's collect it.
76 return UnitTestCase.from_parent(collector, name=name, obj=obj)
77
78
79class UnitTestCase(Class):

Callers

nothing calls this directly

Calls 1

from_parentMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…