Example #1
0
    def set_log_path(self, fname: str) -> None:
        """Public method, which can set filename parameter for
        Logging.FileHandler(). Also creates parent directory if
        it does not exist.

        .. warning::
            Please considered as an experimental API.
        """
        fpath = Path(fname)

        if not fpath.is_absolute():
            fpath = Path(self._config.rootdir, fpath)

        if not fpath.parent.exists():
            fpath.parent.mkdir(exist_ok=True, parents=True)

        stream = fpath.open(mode="w", encoding="UTF-8")
        if sys.version_info >= (3, 7):
            old_stream = self.log_file_handler.setStream(stream)
        else:
            old_stream = self.log_file_handler.stream
            self.log_file_handler.acquire()
            try:
                self.log_file_handler.flush()
                self.log_file_handler.stream = stream
            finally:
                self.log_file_handler.release()
        if old_stream:
            old_stream.close()
Example #2
0
 def __init__(self, config):
     self._config = config
     log_path = Path(config.option.xlog)
     self._log_path = log_path
     log_path.parent.mkdir(parents=True, exist_ok=True)
     self._file = log_path.open("w", buffering=1, encoding="UTF-8")
     self._always_report = {}
     for item in config.option.xopt:
         if '=' in item:
             keytree = item.split('=')[0]
             key = keytree
             cur = self._always_report
             for key in keytree.split('.'):
                 if not cur.get(key):
                     cur[key] = {}
                 if key != keytree.split('.')[-1]:
                     cur = cur[key]
             cur[key] = item.split('=')[1]
     self._always_report['session_id'] = int(time())
     self._results = {}
Example #3
0
def schema():
    """Returns a xmlschema.XMLSchema object for the junit-10.xsd file"""
    fn = Path(__file__).parent / "example_scripts/junit-10.xsd"
    with fn.open() as f:
        return xmlschema.XMLSchema(f)
Example #4
0
    def __init__(self, config, log_path: Path):
        self._config = config
        self._log_path = log_path

        log_path.parent.mkdir(parents=True, exist_ok=True)
        self._file = log_path.open("w", buffering=1, encoding="UTF-8")