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

Function _show_fixture_action

src/_pytest/setuponly.py:60–90  ·  view source on GitHub ↗
(fixturedef: FixtureDef[object], msg: str)

Source from the content-addressed store, hash-verified

58
59
60def _show_fixture_action(fixturedef: FixtureDef[object], msg: str) -> None:
61 config = fixturedef._fixturemanager.config
62 capman = config.pluginmanager.getplugin("capturemanager")
63 if capman:
64 capman.suspend_global_capture()
65
66 tw = config.get_terminal_writer()
67 tw.line()
68 # Use smaller indentation the higher the scope: Session = 0, Package = 1, etc.
69 scope_indent = list(reversed(Scope)).index(fixturedef._scope)
70 tw.write(" " * 2 * scope_indent)
71 tw.write(
72 "{step} {scope} {fixture}".format(
73 step=msg.ljust(8), # align the output to TEARDOWN
74 scope=fixturedef.scope[0].upper(),
75 fixture=fixturedef.argname,
76 )
77 )
78
79 if msg == "SETUP":
80 deps = sorted(arg for arg in fixturedef.argnames if arg != "request")
81 if deps:
82 tw.write(" (fixtures used: {})".format(", ".join(deps)))
83
84 if hasattr(fixturedef, "cached_param"):
85 tw.write(f"[{saferepr(fixturedef.cached_param, maxsize=42)}]") # type: ignore[attr-defined]
86
87 tw.flush()
88
89 if capman:
90 capman.resume_global_capture()
91
92
93@pytest.hookimpl(tryfirst=True)

Callers 2

pytest_fixture_setupFunction · 0.85

Calls 10

safereprFunction · 0.90
getpluginMethod · 0.80
get_terminal_writerMethod · 0.80
indexMethod · 0.80
resume_global_captureMethod · 0.80
lineMethod · 0.45
writeMethod · 0.45
formatMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected