MCPcopy
hub / github.com/pytest-dev/pytest / pytest_configure

Function pytest_configure

src/_pytest/pastebin.py:36–56  ·  src/_pytest/pastebin.py::pytest_configure
(config: Config)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

getpluginMethod · 0.80

Tested by

no test coverage detected