@@ -73,20 +73,24 @@ def check_result(expected_result, result):
73
73
elif prop == "inserted_ids" :
74
74
# BulkWriteResult does not have inserted_ids.
75
75
if isinstance (result , BulkWriteResult ):
76
- return len (expected_result [res ]) == result .inserted_count
77
- # InsertManyResult may be compared to [id1] from the
78
- # crud spec or {"0": id1} from the retryable write spec.
79
- ids = expected_result [res ]
80
- if isinstance (ids , dict ):
81
- ids = [ids [str (i )] for i in range (len (ids ))]
82
- return ids == result .inserted_ids
76
+ if len (expected_result [res ]) != result .inserted_count :
77
+ return False
78
+ else :
79
+ # InsertManyResult may be compared to [id1] from the
80
+ # crud spec or {"0": id1} from the retryable write spec.
81
+ ids = expected_result [res ]
82
+ if isinstance (ids , dict ):
83
+ ids = [ids [str (i )] for i in range (len (ids ))]
84
+ if ids != result .inserted_ids :
85
+ return False
83
86
elif prop == "upserted_ids" :
84
87
# Convert indexes from strings to integers.
85
88
ids = expected_result [res ]
86
89
expected_ids = {}
87
90
for str_index in ids :
88
91
expected_ids [int (str_index )] = ids [str_index ]
89
- return expected_ids == result .upserted_ids
92
+ if expected_ids != result .upserted_ids :
93
+ return False
90
94
elif getattr (result , prop ) != expected_result [res ]:
91
95
return False
92
96
return True
0 commit comments