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

Function _eval_scope_callable

src/_pytest/fixtures.py:940–962  ·  view source on GitHub ↗
(
    scope_callable: "Callable[[str, Config], _ScopeName]",
    fixture_name: str,
    config: Config,
)

Source from the content-addressed store, hash-verified

938
939
940def _eval_scope_callable(
941 scope_callable: "Callable[[str, Config], _ScopeName]",
942 fixture_name: str,
943 config: Config,
944) -> "_ScopeName":
945 try:
946 # Type ignored because there is no typing mechanism to specify
947 # keyword arguments, currently.
948 result = scope_callable(fixture_name=fixture_name, config=config) # type: ignore[call-arg]
949 except Exception as e:
950 raise TypeError(
951 "Error evaluating {} while defining fixture '{}'.\n"
952 "Expected a function with the signature (*, fixture_name, config)".format(
953 scope_callable, fixture_name
954 )
955 ) from e
956 if not isinstance(result, str):
957 fail(
958 "Expected {} to return a 'str' while defining fixture '{}', but it returned:\n"
959 "{!r}".format(scope_callable, fixture_name, result),
960 pytrace=False,
961 )
962 return result
963
964
965@final

Callers 1

__init__Method · 0.85

Calls 2

failFunction · 0.90
formatMethod · 0.45

Tested by

no test coverage detected