Skip to content

Commit 5cbe62f

Browse files
committed
test: validate empty propagators for OTEL_PROPAGATORS="none"
1 parent 883f296 commit 5cbe62f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

opentelemetry-api/tests/propagators/test_propagators.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ def test_propagators(propagators):
5252
@patch.dict(environ, {OTEL_PROPAGATORS: "none"})
5353
@patch("opentelemetry.propagators.composite.CompositePropagator")
5454
def test_no_propagators_loaded(self, mock_compositehttppropagator):
55-
def test_propagators(propagators):
56-
self.assertEqual(
57-
propagators, []
58-
) # Expecting an empty list of propagators
55+
# Verify if exception is raised without the fix
56+
with self.assertRaises(Exception):
57+
from opentelemetry.propagate import get_global_textmap
5958

60-
mock_compositehttppropagator.configure_mock(
61-
**{"side_effect": test_propagators}
62-
)
59+
get_global_textmap()
60+
61+
# Apply fix and verify propagators is empty, with no exception raised
62+
try:
63+
from opentelemetry.propagate import get_global_textmap
64+
65+
mock_compositehttppropagator.assert_called_with(
66+
[]
67+
) # Validate empty list of propagators
68+
except Exception as e:
69+
self.fail(f"Test failed unexpectedly with an exception: {e}")
6370

6471
@patch.dict(environ, {OTEL_PROPAGATORS: "a, b, c "})
6572
@patch("opentelemetry.propagators.composite.CompositePropagator")

0 commit comments

Comments
 (0)