Skip to content

Commit 4318dcc

Browse files
committed
chore: refrain from regex in test case
1 parent 58217e9 commit 4318dcc

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tests/functional/test_logger.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,8 @@ def handler(event, context):
685685

686686
def test_clear_state_keeps_custom_keys(lambda_context, stdout, service_name):
687687
# GIVEN
688-
date_format = "%Y"
689-
location_format = "%(module)s:%(funcName)s:%(lineno)d"
690-
logger = Logger(service=service_name, stream=stdout, location=location_format, datefmt=date_format)
688+
location_format = "%(module)s.%(funcName)s:clear_state"
689+
logger = Logger(service=service_name, stream=stdout, location=location_format, custom_key="foo")
691690

692691
# WHEN clear_state is set
693692
@logger.inject_lambda_context(clear_state=True)
@@ -699,11 +698,9 @@ def handler(event, context):
699698
handler({}, lambda_context)
700699

701700
first_log, second_log = capture_multiple_logging_statements_output(stdout)
702-
703-
assert re.fullmatch("[0-9]{4}", first_log["timestamp"])
704-
assert re.fullmatch("[0-9]{4}", second_log["timestamp"])
705-
assert re.fullmatch(".+:.+:[0-9]+", first_log["location"])
706-
assert re.fullmatch(".+:.+:[0-9]+", second_log["location"])
701+
for log in (first_log, second_log):
702+
assert "foo" == log["custom_key"]
703+
assert "test_logger.handler:clear_state" == log["location"]
707704

708705

709706
def test_clear_state_keeps_exception_keys(lambda_context, stdout, service_name):

0 commit comments

Comments
 (0)