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

Function call_optional

src/_pytest/nose.py:30–42  ·  view source on GitHub ↗
(obj: object, name: str)

Source from the content-addressed store, hash-verified

28
29
30def call_optional(obj: object, name: str) -> bool:
31 method = getattr(obj, name, None)
32 if method is None:
33 return False
34 is_fixture = getfixturemarker(method) is not None
35 if is_fixture:
36 return False
37 if not callable(method):
38 return False
39 # If there are any problems allow the exception to raise rather than
40 # silently ignoring it.
41 method()
42 return True

Callers 3

pytest_runtest_setupFunction · 0.85

Calls 1

getfixturemarkerFunction · 0.90

Tested by 2