Skip to content

Commit b5e344d

Browse files
committed
Fix tests, add comment
1 parent 4f2095a commit b5e344d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

opentelemetry-sdk/tests/test_configurator.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,19 @@ def test_logging_init_exporter(self):
688688
self.assertTrue(provider.processor.exporter.export_called)
689689

690690
def test_logging_init_exporter_uses_exporter_args_map(self):
691-
resource = Resource.create({})
692-
_init_logging(
693-
{"otlp": DummyOTLPLogExporter},
694-
resource=resource,
695-
exporter_args_map={
696-
DummyOTLPLogExporter: {"compression": "gzip"},
697-
DummyOTLPMetricExporter: {"compression": "no"},
698-
},
699-
)
700-
self.assertEqual(self.set_provider_mock.call_count, 1)
701-
provider = self.set_provider_mock.call_args[0][0]
702-
self.assertEqual(provider.processor.exporter.compression, "gzip")
691+
with ResetGlobalLoggingState():
692+
resource = Resource.create({})
693+
_init_logging(
694+
{"otlp": DummyOTLPLogExporter},
695+
resource=resource,
696+
exporter_args_map={
697+
DummyOTLPLogExporter: {"compression": "gzip"},
698+
DummyOTLPMetricExporter: {"compression": "no"},
699+
},
700+
)
701+
self.assertEqual(self.set_provider_mock.call_count, 1)
702+
provider = self.set_provider_mock.call_args[0][0]
703+
self.assertEqual(provider.processor.exporter.compression, "gzip")
703704

704705
@patch.dict(
705706
environ,
@@ -1232,6 +1233,9 @@ def test_custom_configurator(self, mock_init_comp):
12321233
mock_init_comp.assert_called_once_with(**kwargs)
12331234

12341235

1236+
# Any test that calls _init_logging with setup_logging_handler=True
1237+
# should call _init_logging within this context manager, to
1238+
# ensure the global logging state is reset after the test.
12351239
class ResetGlobalLoggingState:
12361240
def __init__(self):
12371241
self.original_basic_config = logging.basicConfig

0 commit comments

Comments
 (0)