Call the given function with the given argument if func accepts one argument, otherwise calls func without arguments.
(func, arg)
| 758 | |
| 759 | |
| 760 | def _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 | |
| 772 | def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]: |
no test coverage detected