Skip to content

Commit d21fa18

Browse files
committed
test: pin config.service=None for AWS service-representation tests
The inferred-span and service-mapping tests assert the AWS service representation, which only applies when DD_SERVICE is unset. CI sets DD_SERVICE, so pin config.service to None to keep them deterministic.
1 parent 2e803bf commit d21fa18

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/test_tracing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,13 @@ def test_set_dd_trace_py_root_none_context(self):
14211421
class TestServiceMapping(unittest.TestCase):
14221422
def setUp(self):
14231423
self.service_mapping = {}
1424+
# These tests exercise the AWS service-representation / service-mapping
1425+
# resolution, which only applies when DD_SERVICE is not set. Pin
1426+
# config.service to None so the tests are deterministic regardless of
1427+
# whether DD_SERVICE is present in the environment (e.g. in CI).
1428+
service_patcher = patch("datadog_lambda.config.Config.service", None)
1429+
service_patcher.start()
1430+
self.addCleanup(service_patcher.stop)
14241431

14251432
def get_service_mapping(self):
14261433
return global_service_mapping
@@ -2614,6 +2621,7 @@ def __init__(self, service, start, span_type, parent_name=None, tags=None):
26142621

26152622
@pytest.mark.parametrize("source,expect", _test_create_inferred_span)
26162623
@patch("ddtrace.trace.Span.finish", autospec=True)
2624+
@patch("datadog_lambda.config.Config.service", None)
26172625
def test_create_inferred_span(mock_span_finish, source, expect):
26182626
with open(f"{event_samples}{source}.json") as f:
26192627
event = json.load(f)

0 commit comments

Comments
 (0)