Skip to content

Commit 552c73d

Browse files
committed
Use caplog to capture test records
1 parent 57dbc36 commit 552c73d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tests/ext/aiohttp/test_client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async def test_no_segment_raise(loop, recorder):
145145
pass
146146

147147

148-
async def test_no_segment_log_error(loop, recorder, capsys):
148+
async def test_no_segment_log_error(loop, recorder, caplog):
149149
xray_recorder.configure(context_missing='LOG_ERROR')
150150
trace_config = aws_xray_trace_config()
151151
status_code = 200
@@ -156,11 +156,10 @@ async def test_no_segment_log_error(loop, recorder, capsys):
156156

157157
# Just check that the request was done correctly
158158
assert status_received == status_code
159-
captured = capsys.readouterr()
160-
assert MISSING_SEGMENT_MSG in captured.out
159+
assert [MISSING_SEGMENT_MSG] == [rec.message for rec in caplog.records]
161160

162161

163-
async def test_no_segment_ignore(loop, recorder, capsys):
162+
async def test_no_segment_ignore(loop, recorder, caplog):
164163
xray_recorder.configure(context_missing='IGNORE')
165164
trace_config = aws_xray_trace_config()
166165
status_code = 200
@@ -171,5 +170,4 @@ async def test_no_segment_ignore(loop, recorder, capsys):
171170

172171
# Just check that the request was done correctly
173172
assert status_received == status_code
174-
captured = capsys.readouterr()
175-
assert MISSING_SEGMENT_MSG not in captured.out
173+
assert [] == [rec.message for rec in caplog.records]

0 commit comments

Comments
 (0)