1
+ import logging
2
+
1
3
import pytest
2
4
from aiohttp import ClientSession
3
5
@@ -145,7 +147,8 @@ async def test_no_segment_raise(loop, recorder):
145
147
pass
146
148
147
149
148
- async def test_no_segment_log_error (loop , recorder , capsys ):
150
+ async def test_no_segment_log_error (loop , recorder , caplog ):
151
+ caplog .set_level (logging .ERROR )
149
152
xray_recorder .configure (context_missing = 'LOG_ERROR' )
150
153
trace_config = aws_xray_trace_config ()
151
154
status_code = 200
@@ -156,11 +159,11 @@ async def test_no_segment_log_error(loop, recorder, capsys):
156
159
157
160
# Just check that the request was done correctly
158
161
assert status_received == status_code
159
- captured = capsys .readouterr ()
160
- assert MISSING_SEGMENT_MSG in captured .out
162
+ assert MISSING_SEGMENT_MSG in [rec .message for rec in caplog .records ]
161
163
162
164
163
- async def test_no_segment_ignore (loop , recorder , capsys ):
165
+ async def test_no_segment_ignore (loop , recorder , caplog ):
166
+ caplog .set_level (logging .ERROR )
164
167
xray_recorder .configure (context_missing = 'IGNORE' )
165
168
trace_config = aws_xray_trace_config ()
166
169
status_code = 200
@@ -171,5 +174,4 @@ async def test_no_segment_ignore(loop, recorder, capsys):
171
174
172
175
# Just check that the request was done correctly
173
176
assert status_received == status_code
174
- captured = capsys .readouterr ()
175
- assert MISSING_SEGMENT_MSG not in captured .out
177
+ assert MISSING_SEGMENT_MSG not in [rec .message for rec in caplog .records ]
0 commit comments