def test_stderr(self, capsys, command, ignore_stderr_regexp, out_regexp, expected): from loguru import logger import subprocrunner logger.remove() logger.add(sys.stderr, level="DEBUG") logger.enable("test") subprocrunner.set_logger(True) runner = SubprocessRunner(command, ignore_stderr_regexp=ignore_stderr_regexp) runner.run() assert is_null_string(runner.stdout.strip()) assert is_not_null_string(runner.stderr.strip()) assert runner.returncode != 0 out, err = capsys.readouterr() print("[sys stdout]\n{}\n".format(out)) print("[sys stderr]\n{}\n".format(err)) print("[proc stdout]\n{}\n".format(runner.stdout)) print("[proc stderr]\n{}\n".format(runner.stderr)) actual = out_regexp.search(err) is not None assert actual == expected
def run_command_helper(command, error_regexp, message, exception=None): if logger.level != logbook.DEBUG: spr.set_logger(is_enable=False) proc = spr.SubprocessRunner(command) proc.run() if logger.level != logbook.DEBUG: spr.set_logger(is_enable=True) if proc.returncode == 0: return 0 match = error_regexp.search(proc.stderr) if match is None: logger.error(proc.stderr) return proc.returncode if typepy.is_not_null_string(message): logger.notice(message) if exception is not None: raise exception(command) return proc.returncode
def set_logger(is_enable): if is_enable: logger.enable() else: logger.disable() subprocrunner.set_logger(is_enable)
def set_logger(is_enable): if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) simplesqlite.set_logger(is_enable) subprocrunner.set_logger(is_enable)
def set_logger(is_enable: bool, propagation_depth: int = 1) -> None: if is_enable: logger.enable(MODULE_NAME) else: logger.disable(MODULE_NAME) if propagation_depth <= 0: return subprocrunner.set_logger(is_enable, propagation_depth - 1)
def set_logger(is_enable): if is_enable != logger.disabled: # logger setting have not changed return if is_enable: logger.enable() else: logger.disable() subprocrunner.set_logger(is_enable)
def set_logger(is_enable): if is_enable != logger.disabled: # logger setting have not changed return if is_enable: logger.enable() else: logger.disable() simplesqlite.set_logger(is_enable) subprocrunner.set_logger(is_enable)
def set_logger(is_enable): if is_enable != logger.disabled: # logger setting have not changed return if is_enable: logger.enable() else: logger.disable() subprocrunner.set_logger(is_enable) ptw.set_logger(is_enable) appconfigpy.set_logger(is_enable)
def set_logger(is_enable): if is_enable != logger.disabled: # logger setting have not changed return if is_enable: try: logger.enable() except AttributeError: logger.disabled = False # to support Logbook<1.0.0 else: _disable_logger(logger) subprocrunner.set_logger(is_enable)
def test_smoke(self, value, monkeypatch): monkeypatch.setattr("subprocrunner._logger._logger.logger", NullLogger()) set_logger(value)
def test_smoke(self, value): set_logger(value)