Skip to content

Commit 07f5b32

Browse files
committed
Use caplog to capture test records
1 parent 57dbc36 commit 07f5b32

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/ext/aiohttp/test_client.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import logging
2+
13
import pytest
24
from aiohttp import ClientSession
35

@@ -145,7 +147,8 @@ async def test_no_segment_raise(loop, recorder):
145147
pass
146148

147149

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)
149152
xray_recorder.configure(context_missing='LOG_ERROR')
150153
trace_config = aws_xray_trace_config()
151154
status_code = 200
@@ -156,11 +159,11 @@ async def test_no_segment_log_error(loop, recorder, capsys):
156159

157160
# Just check that the request was done correctly
158161
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]
161163

162164

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)
164167
xray_recorder.configure(context_missing='IGNORE')
165168
trace_config = aws_xray_trace_config()
166169
status_code = 200
@@ -171,5 +174,4 @@ async def test_no_segment_ignore(loop, recorder, capsys):
171174

172175
# Just check that the request was done correctly
173176
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

Comments
 (0)