Skip to content

Commit 61cddb0

Browse files
committed
improv: update root logger test
1 parent 3ea4fbb commit 61cddb0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/functional/test_logger.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,18 @@ def test_logger_record_caller_location(stdout):
361361
assert caller_fn_name in log["location"]
362362

363363

364-
def test_logger_do_not_log_twice(stdout):
364+
def test_logger_do_not_log_twice_when_root_logger_is_setup(stdout):
365365
# GIVEN Lambda configures the root logger with a handler
366-
logging.basicConfig(format="%(asctime)-15s %(clientip)s %(user)-8s %(message)s", level="INFO")
367366
root_logger = logging.getLogger()
368367
root_logger.addHandler(logging.StreamHandler(stream=stdout))
369368

370-
# WHEN we create a new Logger
369+
# WHEN we create a new Logger and child Logger
371370
logger = Logger(stream=stdout)
371+
child_logger = Logger(child=True, stream=stdout)
372372
logger.info("hello")
373+
child_logger.info("hello again")
373374

374-
# THEN it should fail to unpack because root logger handler
375-
# should be removed as part of our Logger initialization
376-
assert not root_logger.handlers
377-
with pytest.raises(ValueError, match=r".*expected 2, got 1.*"):
378-
[log_one, log_two] = stdout.getvalue().strip().split("\n")
375+
# THEN it should only contain only two log entries
376+
# since child's log records propagated to root logger should be rejected
377+
logs = list(stdout.getvalue().strip().split("\n"))
378+
assert len(logs) == 2

0 commit comments

Comments
 (0)