From bbe66be966ce876adafe8e25fea9cb33c7e3597f Mon Sep 17 00:00:00 2001 From: Petr Heinz Date: Tue, 10 Dec 2024 15:04:34 +0100 Subject: [PATCH] add failing test --- tests/test_handler.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_handler.py b/tests/test_handler.py index bd10255..c8d860d 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -224,6 +224,27 @@ def test_can_have_multiple_instance_of_same_string_in_extra_data(self, MockWorke self.assertEqual(log_entry['test2'], 'this is a test string') self.assertTrue(handler.pipe.empty()) + @patch('logtail.handler.FlushWorker') + def test_can_have_multiple_instance_of_same_array_in_extra_data(self, MockWorker): + buffer_capacity = 1 + handler = LogtailHandler( + source_token=self.source_token, + buffer_capacity=buffer_capacity + ) + + logger = logging.getLogger(__name__) + logger.handlers = [] + logger.addHandler(handler) + test_array = ['this is a test string'] + logger.info('hello', extra={'test1': test_array, 'test2': test_array}) + + log_entry = handler.pipe.get() + + self.assertEqual(log_entry['message'], 'hello') + self.assertEqual(log_entry['test1'], ['this is a test string']) + self.assertEqual(log_entry['test2'], ['this is a test string']) + self.assertTrue(handler.pipe.empty()) + @patch('logtail.handler.FlushWorker') def test_can_send_circular_dependency_in_context(self, MockWorker): buffer_capacity = 1