@@ -37,15 +37,15 @@ async def test_default_truncation_limit(self):
37
37
with self .assertLogs ("pymongo.command" , level = "DEBUG" ) as cm :
38
38
await db .test .insert_many (docs )
39
39
40
- cmd_started_log = json_util .loads (cm .records [0 ].message )
40
+ cmd_started_log = json_util .loads (cm .records [0 ].getMessage () )
41
41
self .assertEqual (len (cmd_started_log ["command" ]), _DEFAULT_DOCUMENT_LENGTH + 3 )
42
42
43
- cmd_succeeded_log = json_util .loads (cm .records [1 ].message )
43
+ cmd_succeeded_log = json_util .loads (cm .records [1 ].getMessage () )
44
44
self .assertLessEqual (len (cmd_succeeded_log ["reply" ]), _DEFAULT_DOCUMENT_LENGTH + 3 )
45
45
46
46
with self .assertLogs ("pymongo.command" , level = "DEBUG" ) as cm :
47
47
await db .test .find ({}).to_list ()
48
- cmd_succeeded_log = json_util .loads (cm .records [1 ].message )
48
+ cmd_succeeded_log = json_util .loads (cm .records [1 ].getMessage () )
49
49
self .assertEqual (len (cmd_succeeded_log ["reply" ]), _DEFAULT_DOCUMENT_LENGTH + 3 )
50
50
51
51
async def test_configured_truncation_limit (self ):
@@ -55,14 +55,14 @@ async def test_configured_truncation_limit(self):
55
55
with self .assertLogs ("pymongo.command" , level = "DEBUG" ) as cm :
56
56
await db .command (cmd )
57
57
58
- cmd_started_log = json_util .loads (cm .records [0 ].message )
58
+ cmd_started_log = json_util .loads (cm .records [0 ].getMessage () )
59
59
self .assertEqual (len (cmd_started_log ["command" ]), 5 + 3 )
60
60
61
- cmd_succeeded_log = json_util .loads (cm .records [1 ].message )
61
+ cmd_succeeded_log = json_util .loads (cm .records [1 ].getMessage () )
62
62
self .assertLessEqual (len (cmd_succeeded_log ["reply" ]), 5 + 3 )
63
63
with self .assertRaises (OperationFailure ):
64
64
await db .command ({"notARealCommand" : True })
65
- cmd_failed_log = json_util .loads (cm .records [- 1 ].message )
65
+ cmd_failed_log = json_util .loads (cm .records [- 1 ].getMessage () )
66
66
self .assertEqual (len (cmd_failed_log ["failure" ]), 5 + 3 )
67
67
68
68
async def test_truncation_multi_byte_codepoints (self ):
@@ -78,7 +78,7 @@ async def test_truncation_multi_byte_codepoints(self):
78
78
with patch .dict ("os.environ" , {"MONGOB_LOG_MAX_DOCUMENT_LENGTH" : length }):
79
79
with self .assertLogs ("pymongo.command" , level = "DEBUG" ) as cm :
80
80
await self .db .test .insert_one ({"x" : multi_byte_char_str })
81
- cmd_started_log = json_util .loads (cm .records [0 ].message )["command" ]
81
+ cmd_started_log = json_util .loads (cm .records [0 ].getMessage () )["command" ]
82
82
83
83
cmd_started_log = cmd_started_log [:- 3 ]
84
84
last_3_bytes = cmd_started_log .encode ()[- 3 :].decode ()
0 commit comments