def __init__(self): super(EngineEmul, self).__init__(logging.getLogger('')) directory = get_full_path(TEST_DIR) prefix = datetime.datetime.now().strftime(self.ARTIFACTS_DIR) self.config.merge({ "provisioning": "local", "modules": { "mock": ModuleMock.__module__ + "." + ModuleMock.__name__, "local": ModuleMock.__module__ + "." + ModuleMock.__name__}, "settings": { "check-updates": False, "artifacts-dir": get_uniq_name(directory=directory, prefix=prefix)}}) self.create_artifacts_dir() self.prepare_exc = None self.was_finalize = False
def create_artifact(self, prefix, suffix): """ Create new artifact in artifacts dir with given prefix and suffix :type prefix: str :type suffix: str :return: Path to created file :rtype: str :raise TaurusInternalException: if no artifacts dir set """ if not self.artifacts_dir: raise TaurusInternalException("Cannot create artifact: no artifacts_dir set up") filename = get_uniq_name(self.artifacts_dir, prefix, suffix, self.__artifacts) self.__artifacts.append(filename) self.log.debug("New artifact filename: %s", filename) return filename
def create_artifact(self, prefix, suffix): """ Create new artifact in artifacts dir with given prefix and suffix :type prefix: str :type suffix: str :return: Path to created file :rtype: str :raise TaurusInternalException: if no artifacts dir set """ if not self.artifacts_dir: raise TaurusInternalException( "Cannot create artifact: no artifacts_dir set up") filename = get_uniq_name(self.artifacts_dir, prefix, suffix, self.__artifacts) self.__artifacts.append(filename) self.log.debug("New artifact filename: %s", filename) return filename
def test_streams(self): self.sniff_log() print('test1') with log_std_streams(logger=self.captured_logger, stdout_level=logging.DEBUG): print('test2') with log_std_streams(stdout_level=logging.DEBUG): print('test3') with log_std_streams(stdout_level=logging.DEBUG): sys.stdout.write('test3') with log_std_streams(logger=self.captured_logger, stdout_level=logging.DEBUG): cmd = ['echo', '"test5"'] if is_windows(): cmd = ['cmd', '/c'] + cmd process = Popen(cmd) process.wait() missed_file = get_uniq_name('.', 'test6', '') with log_std_streams(logger=self.captured_logger, stderr_level=logging.WARNING): if is_windows(): cmd = ['cmd', '/c', 'dir'] else: cmd = ['ls'] process = Popen(cmd + [missed_file]) process.wait() debug_buf = self.log_recorder.debug_buff.getvalue() warn_buf = self.log_recorder.warn_buff.getvalue() self.assertNotIn('test1', debug_buf) self.assertIn('test2', debug_buf) self.assertNotIn('test3', debug_buf) self.assertIn('test5', debug_buf) self.assertTrue(len(warn_buf) > 0)
def __init__(self): super(EngineEmul, self).__init__(logging.getLogger('')) directory = get_full_path(TEST_DIR) prefix = datetime.datetime.now().strftime(self.ARTIFACTS_DIR) self.config.merge({ "provisioning": "local", "modules": { "mock": ModuleMock.__module__ + "." + ModuleMock.__name__, "local": ModuleMock.__module__ + "." + ModuleMock.__name__ }, "settings": { "check-updates": False, "artifacts-dir": get_uniq_name(directory=directory, prefix=prefix) } }) self.create_artifacts_dir() self.prepare_exc = None self.was_finalize = False
def __init__(self): super(EngineEmul, self).__init__(ROOT_LOGGER) self.aggregator.add_underling = lambda _: None directory = get_full_path(TEST_DIR) prefix = datetime.datetime.now().strftime(self.ARTIFACTS_DIR) self.config.merge({ "provisioning": "local", "modules": { "mock": ModuleMock.__module__ + "." + ModuleMock.__name__, "local": ModuleMock.__module__ + "." + ModuleMock.__name__ }, "settings": { "check-updates": False, "artifacts-dir": get_uniq_name(directory=directory, prefix=prefix) } }) self.check_interval = 0.1 self.create_artifacts_dir() self.prepare_exc = None self.was_finalize = False