1+ import logging
2+
13import datetime
24import json
35import re
@@ -453,7 +455,9 @@ def lambda_test_function(event, context):
453455 assert enrichment_spans [0 ][EXECUTION_TAGS_KEY ] == [{"key" : key , "value" : "my_value" }]
454456
455457
456- def test_not_jsonable_return (monkeypatch , context ):
458+ def test_not_jsonable_return_value_python37 (monkeypatch , context ):
459+ monkeypatch .setenv ("AWS_EXECUTION_ENV" , "AWS_Lambda_python3.7" )
460+
457461 @lumigo_tracer ()
458462 def lambda_test_function (event , context ):
459463 return {"a" : datetime .datetime .now ()}
@@ -468,6 +472,26 @@ def lambda_test_function(event, context):
468472 assert function_span ["error" ]["message" ] == expected_message
469473
470474
475+ def test_not_jsonable_return_value_non_python37 (monkeypatch , context , caplog ):
476+ monkeypatch .setenv ("AWS_EXECUTION_ENV" , "AWS_Lambda_python3.8" )
477+
478+ @lumigo_tracer ()
479+ def lambda_test_function (event , context ):
480+ return {"a" : datetime .datetime .now ()}
481+
482+ lambda_test_function ({}, context )
483+
484+ function_span = SpansContainer .get_span ().function_span
485+ assert function_span ["return_value" ] is None
486+ assert "error" not in function_span
487+ assert next (
488+ log
489+ for log in caplog .records
490+ if log .levelno == logging .ERROR
491+ and "Could not serialize the return value of the lambda" in log .message
492+ )
493+
494+
471495@mock_kinesis
472496def test_china (context , reporter_mock , monkeypatch ):
473497 china_region_for_test = "ap-east-1" # Moto doesn't work for China
0 commit comments