File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 11# This Source Code Form is subject to the terms of the Mozilla Public
22# License, v. 2.0. If a copy of the MPL was not distributed with this
33# file, you can obtain one at http://mozilla.org/MPL/2.0/.
4- import io
54import json
65import logging
76
@@ -95,13 +94,8 @@ def test_mozlog_without_correlation_id_middleware(client, caplog):
9594
9695
9796def test_request_id_passed_to_all_log_messages (caplog ):
98- buffer = io .StringIO ()
99- handler = logging .StreamHandler (stream = buffer )
100- handler .addFilter (RequestIdLogFilter ())
101- handler .setFormatter (JsonLogFormatter ())
102-
103- _logger = logging .getLogger ("some_logger" )
104- _logger .addHandler (handler )
97+ caplog .handler .addFilter (RequestIdLogFilter ())
98+ caplog .handler .setFormatter (JsonLogFormatter ())
10599
106100 app = create_app ()
107101
@@ -115,9 +109,9 @@ def ping():
115109
116110 client .get ("/ping" )
117111
118- parsed_log = json .loads (buffer .getvalue ())
119112 log_message = next (r for r in caplog .records if r .name == "some_logger" )
120113 assert log_message .rid is not None
114+ parsed_log = json .loads (caplog .text .splitlines ()[0 ])
121115 assert "rid" in parsed_log ["Fields" ]
122116
123117
You can’t perform that action at this time.
0 commit comments