def setup_capture(self): if self.config.stdout_capture: self.stdout_capture = io.StringIO() self.context.stdout_capture = self.stdout_capture if self.config.stderr_capture: self.stderr_capture = io.StringIO() self.context.stderr_capture = self.stderr_capture if self.config.log_capture: self.log_capture = LoggingCapture(self.config) self.log_capture.inveigle() self.context.log_capture = self.log_capture
def step_I_capture_logrecords(context): """ .. code-block: gherkin Given I capture log records When I capture log records :param context: """ raise NotImplementedError() logcapture = getattr(context, "logcapture", None) if not logcapture: context.logcapture = LoggingCapture()
def setup_capture(self, context): assert context is not None if self.config.stdout_capture: self.stdout_capture = StringIO() context.stdout_capture = self.stdout_capture if self.config.stderr_capture: self.stderr_capture = StringIO() context.stderr_capture = self.stderr_capture if self.config.log_capture: self.log_capture = LoggingCapture(self.config) self.log_capture.inveigle() context.log_capture = self.log_capture
def test_get_value_returns_all_log_records(self): class FakeConfig(object): logging_filter = None logging_format = None logging_datefmt = None logging_level = None fake_records = [object() for x in range(0, 10)] handler = LoggingCapture(FakeConfig()) handler.buffer = fake_records with patch.object(handler.formatter, 'format') as format: format.return_value = 'foo' expected = '\n'.join(['foo'] * len(fake_records)) eq_(handler.getvalue(), expected) calls = [args[0][0] for args in format.call_args_list] eq_(calls, fake_records)