Example #1
0
    def test_emit_different_error_level_writes_immeditely_string(self):
        stream = io.StringIO()
        bsh = BufferStreamHandler(stream)
        rec = logging.LogRecord('test_name', logging.ERROR, 'pathname', 123,
                                'error message', (), None)
        bsh.emit(rec)

        self.assertEqual(len(bsh.message_buffer['items']), 1)
        self.assertEqual(stream.getvalue().strip(), 'error message')
Example #2
0
    def test_emit_string(self):
        stream = io.StringIO()
        bsh = BufferStreamHandler(stream)
        rec = logging.LogRecord('test_name', logging.INFO, 'pathname', 123,
                                'string', (), None)
        # setting to empty, seems something else is writing to it somehow
        bsh.emit(rec)

        self.assertEqual(len(bsh.message_buffer['items']), 1)
        self.assertEqual(stream.getvalue().strip(), '')