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

Function pytest_configure

src/_pytest/pastebin.py:32–49  ·  view source on GitHub ↗
(config: Config)

Source from the content-addressed store, hash-verified

30
31@pytest.hookimpl(trylast=True)
32def pytest_configure(config: Config) -> None:
33 if config.option.pastebin == "all":
34 tr = config.pluginmanager.getplugin("terminalreporter")
35 # If no terminal reporter plugin is present, nothing we can do here;
36 # this can happen when this function executes in a worker node
37 # when using pytest-xdist, for example.
38 if tr is not None:
39 # pastebin file will be UTF-8 encoded binary file.
40 config.stash[pastebinfile_key] = tempfile.TemporaryFile("w+b")
41 oldwrite = tr._tw.write
42
43 def tee_write(s, **kwargs):
44 oldwrite(s, **kwargs)
45 if isinstance(s, str):
46 s = s.encode("utf-8")
47 config.stash[pastebinfile_key].write(s)
48
49 tr._tw.write = tee_write
50
51
52def pytest_unconfigure(config: Config) -> None:

Callers

nothing calls this directly

Calls 1

getpluginMethod · 0.80

Tested by

no test coverage detected