(collector: "PyCollector", name: str, obj: object)
| 225 | |
| 226 | @hookimpl(trylast=True) |
| 227 | def pytest_pycollect_makeitem(collector: "PyCollector", name: str, obj: object): |
| 228 | # Nothing was collected elsewhere, let's do it here. |
| 229 | if safe_isclass(obj): |
| 230 | if collector.istestclass(obj, name): |
| 231 | return Class.from_parent(collector, name=name, obj=obj) |
| 232 | elif collector.istestfunction(obj, name): |
| 233 | # mock seems to store unbound methods (issue473), normalize it. |
| 234 | obj = getattr(obj, "__func__", obj) |
| 235 | # We need to try and unwrap the function if it's a functools.partial |
| 236 | # or a functools.wrapped. |
| 237 | # We mustn't if it's been wrapped with mock.patch (python 2 only). |
| 238 | if not (inspect.isfunction(obj) or inspect.isfunction(get_real_func(obj))): |
| 239 | filename, lineno = getfslineno(obj) |
| 240 | warnings.warn_explicit( |
| 241 | message=PytestCollectionWarning( |
| 242 | "cannot collect %r because it is not a function." % name |
| 243 | ), |
| 244 | category=None, |
| 245 | filename=str(filename), |
| 246 | lineno=lineno + 1, |
| 247 | ) |
| 248 | elif getattr(obj, "__test__", True): |
| 249 | if is_generator(obj): |
| 250 | res = Function.from_parent(collector, name=name) |
| 251 | reason = "yield tests were removed in pytest 4.0 - {name} will be ignored".format( |
| 252 | name=name |
| 253 | ) |
| 254 | res.add_marker(MARK_GEN.xfail(run=False, reason=reason)) |
| 255 | res.warn(PytestCollectionWarning(reason)) |
| 256 | else: |
| 257 | res = list(collector._genfunctions(name, obj)) |
| 258 | return res |
| 259 | |
| 260 | |
| 261 | class PyobjMixin(nodes.Node): |
nothing calls this directly
no test coverage detected