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

Function _call_with_optional_argument

src/_pytest/python.py:760–769  ·  view source on GitHub ↗

Call the given function with the given argument if func accepts one argument, otherwise calls func without arguments.

(func, arg)

Source from the content-addressed store, hash-verified

758
759
760def _call_with_optional_argument(func, arg) -> None:
761 """Call the given function with the given argument if func accepts one argument, otherwise
762 calls func without arguments."""
763 arg_count = func.__code__.co_argcount
764 if inspect.ismethod(func):
765 arg_count -= 1
766 if arg_count:
767 func(arg)
768 else:
769 func()
770
771
772def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]:

Callers 5

setupMethod · 0.85

Calls 1

funcFunction · 0.70

Tested by

no test coverage detected