(config: Config)
| 34 | |
| 35 | @pytest.hookimpl(trylast=True) |
| 36 | def 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 | |
| 59 | def pytest_unconfigure(config: Config) -> None: |
nothing calls this directly
no test coverage detected