@@ -62,10 +62,10 @@ def div(a, b):
62
62
except Exception as e :
63
63
log .error ('an Exception trace should preceed this msg' , exc_info = True )
64
64
div (1 , 0 )
65
- assert 'an Exception trace' in caplog .text ()
66
- assert 'Traceback' in caplog .text ()
65
+ assert 'an Exception trace' in caplog .text
66
+ assert 'Traceback' in caplog .text
67
67
div (1 , 1 )
68
- assert 'the stack' in caplog .text ()
68
+ assert 'the stack' in caplog .text
69
69
70
70
71
71
def test_listeners (caplog ):
@@ -80,17 +80,17 @@ def log_cb(event_dict):
80
80
# activate listener
81
81
slogging .log_listeners .append (log_cb ) # Add handlers
82
82
log .error ('test listener' , abc = 'thislistener' )
83
- assert 'thislistener' in caplog .text ()
83
+ assert 'thislistener' in caplog .text
84
84
r = called .pop ()
85
85
assert r == dict (event = 'test listener' , abc = 'thislistener' )
86
86
87
87
log .trace ('trace is usually filtered' , abc = 'thislistener' ) # this handler for function log_cb does not work
88
- assert "trace is usually filtered" not in caplog .text ()
88
+ assert "trace is usually filtered" not in caplog .text
89
89
90
90
# deactivate listener
91
91
slogging .log_listeners .remove (log_cb )
92
92
log .error ('test listener' , abc = 'nolistener' )
93
- assert 'nolistener' in caplog .text ()
93
+ assert 'nolistener' in caplog .text
94
94
assert not called
95
95
96
96
@@ -161,7 +161,7 @@ def test_recorder(caplog):
161
161
recorder = slogging .LogRecorder ()
162
162
assert len (slogging .log_listeners ) == 1
163
163
log .info ('a' , v = 1 )
164
- assert "a" in caplog .text ()
164
+ assert "a" in caplog .text
165
165
r = recorder .pop_records ()
166
166
assert r [0 ] == dict (event = 'a' , v = 1 )
167
167
assert len (slogging .log_listeners ) == 0
@@ -171,7 +171,7 @@ def test_recorder(caplog):
171
171
recorder = slogging .LogRecorder ()
172
172
assert len (slogging .log_listeners ) == 1
173
173
log .trace ('a' , v = 2 )
174
- assert '"v": 2' in caplog .text ()
174
+ assert '"v": 2' in caplog .text
175
175
r = recorder .pop_records ()
176
176
assert r [0 ] == dict (event = 'a' , v = 2 )
177
177
assert len (slogging .log_listeners ) == 0
@@ -224,9 +224,9 @@ def test_logger_filter(caplog, logger_name, filter, should_log):
224
224
log .addFilter (logging .Filter (filter ))
225
225
log .info ("testlogmessage" , v = 1 )
226
226
if should_log :
227
- assert "testlogmessage" in caplog .text ()
227
+ assert "testlogmessage" in caplog .text
228
228
else :
229
- assert "testlogmessage" not in caplog .text ()
229
+ assert "testlogmessage" not in caplog .text
230
230
231
231
232
232
def test_bound_logger (caplog ):
@@ -236,15 +236,15 @@ def test_bound_logger(caplog):
236
236
bound_log_1 = real_log .bind (key1 = "value1" )
237
237
with caplog .at_level (slogging .TRACE ):
238
238
bound_log_1 .info ("test1" )
239
- assert "test1" in caplog .text ()
240
- assert "key1=value1" in caplog .text ()
239
+ assert "test1" in caplog .text
240
+ assert "key1=value1" in caplog .text
241
241
242
242
bound_log_2 = bound_log_1 .bind (key2 = "value2" )
243
243
with caplog .at_level (slogging .TRACE ):
244
244
bound_log_2 .info ("test2" )
245
- assert "test2" in caplog .text ()
246
- assert "key1=value1" in caplog .text ()
247
- assert "key2=value2" in caplog .text ()
245
+ assert "test2" in caplog .text
246
+ assert "key1=value1" in caplog .text
247
+ assert "key2=value2" in caplog .text
248
248
249
249
250
250
def test_bound_logger_isolation (caplog ):
0 commit comments