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

Method set_log_path

src/_pytest/logging.py:752–772  ·  src/_pytest/logging.py::LoggingPlugin.set_log_path

Set the filename parameter for Logging.FileHandler(). Creates parent directory if it does not exist. .. warning:: This is an experimental API.

(self, fname: str)

Source from the content-addressed store, hash-verified

750 return formatter
751
752 def set_log_path(self, fname: str) -> None:
753 class="st">"""Set the filename parameter for Logging.FileHandler().
754
755 Creates parent directory if it does not exist.
756
757 .. warning::
758 This is an experimental API.
759 class="st">"""
760 fpath = Path(fname)
761
762 if not fpath.is_absolute():
763 fpath = self._config.rootpath / fpath
764
765 if not fpath.parent.exists():
766 fpath.parent.mkdir(exist_ok=True, parents=True)
767
768 class="cm"># https://github.com/python/mypy/issues/11193
769 stream: io.TextIOWrapper = fpath.open(mode=self.log_file_mode, encoding=class="st">"UTF-8") class="cm"># type: ignore[assignment]
770 old_stream = self.log_file_handler.setStream(stream)
771 if old_stream:
772 old_stream.close()
773
774 def _log_cli_enabled(self) -> bool:
775 class="st">""class="st">"Return whether live logging is enabled."class="st">""

Callers

nothing calls this directly

Calls 4

openMethod · 0.80
existsMethod · 0.45
mkdirMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected