Skip to content

Commit c956ade

Browse files
fix log injection assertions
1 parent 6fb13e6 commit c956ade

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/test_tracing.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,13 +1045,15 @@ def test_set_correlation_ids(self):
10451045
self.assertEqual(span.parent_id, int(fake_xray_header_value_parent_decimal))
10461046
span.finish()
10471047

1048+
@patch("datadog_lambda.config.Config.trace_enabled", False)
10481049
def test_set_correlation_ids_handle_empty_trace_context(self):
1049-
# neither x-ray or ddtrace is used. no tracing context at all.
1050+
# Incomplete trace context: no dummy span should be created. Do not assert
1051+
# tracer.current_span() is None — pytest's CI Visibility plugin (--ddtrace)
1052+
# keeps a root test span active for the duration of the test.
10501053
self.mock_get_dd_trace_context.return_value = Context()
1051-
# no exception thrown
1052-
set_correlation_ids()
1053-
span = tracer.current_span()
1054-
self.assertIsNone(span)
1054+
with patch.object(tracer, "trace") as mock_trace:
1055+
set_correlation_ids()
1056+
mock_trace.assert_not_called()
10551057

10561058

10571059
def _expected_span_pointer_link(

0 commit comments

Comments
 (0)