@@ -205,32 +205,20 @@ def test_hash_consistency(fixture_name, request):
205205 assert hash (obj ) == hash (obj )
206206
207207
208- @pytest .mark .parametrize ("fixture_name" , API_TYPES )
209- def test_hash_not_small (fixture_name , request ):
210- """Hash should not be a small number (guards against returning IDs or indices)."""
211- # Heuristic test guarding against poor hashes likely to collide, e.g.,
212- # hash(device.device_id).
213- obj = request .getfixturevalue (fixture_name )
214- h = hash (obj )
215- assert abs (h ) >= 10 , f"hash { h } is suspiciously small"
216-
217-
218208@pytest .mark .parametrize ("a_name,b_name" , SAME_TYPE_PAIRS )
219209def test_hash_distinct_same_type (a_name , b_name , request ):
220210 """Distinct objects of the same type have different hashes."""
221- # As a practical matter, the chance of collision is extremely low or even
222- # zero; failure here likely indicates a bug.
223211 obj_a = request .getfixturevalue (a_name )
224212 obj_b = request .getfixturevalue (b_name )
225- assert hash (obj_a ) != hash (obj_b ), f" { a_name } and { b_name } have same hash but different handles"
213+ assert hash (obj_a ) != hash (obj_b ) # extremely unlikely
226214
227215
228216@pytest .mark .parametrize ("a_name,b_name" , itertools .combinations (API_TYPES , 2 ))
229217def test_hash_distinct_cross_type (a_name , b_name , request ):
230218 """Distinct objects of different types have different hashes."""
231219 obj_a = request .getfixturevalue (a_name )
232220 obj_b = request .getfixturevalue (b_name )
233- assert hash (obj_a ) != hash (obj_b ), f" { a_name } and { b_name } have same hash"
221+ assert hash (obj_a ) != hash (obj_b ) # extremely unlikely
234222
235223
236224# =============================================================================
@@ -242,37 +230,37 @@ def test_hash_distinct_cross_type(a_name, b_name, request):
242230def test_equality_basic (fixture_name , request ):
243231 """Object equality: reflexive, not equal to None or other types."""
244232 obj = request .getfixturevalue (fixture_name )
245- assert obj == obj , "reflexive equality failed"
246- assert obj != None , "should not equal None" # noqa: E711
247- assert obj != "string" , "should not equal unrelated type"
233+ assert obj == obj
234+ assert obj != None # noqa: E711
235+ assert obj != "string"
248236 if hasattr (obj , "handle" ):
249- assert obj != obj .handle , "should not equal its own handle"
237+ assert obj != obj .handle
250238
251239
252240@pytest .mark .parametrize ("a_name,b_name" , itertools .combinations (API_TYPES , 2 ))
253241def test_no_cross_type_equality (a_name , b_name , request ):
254242 """No two distinct objects of different types should compare equal."""
255243 obj_a = request .getfixturevalue (a_name )
256244 obj_b = request .getfixturevalue (b_name )
257- assert obj_a != obj_b , f" { a_name } == { b_name } but they are distinct objects"
245+ assert obj_a != obj_b
258246
259247
260248@pytest .mark .parametrize ("a_name,b_name" , SAME_TYPE_PAIRS )
261249def test_same_type_inequality (a_name , b_name , request ):
262250 """Two distinct objects of the same type should not compare equal."""
263251 obj_a = request .getfixturevalue (a_name )
264252 obj_b = request .getfixturevalue (b_name )
265- assert obj_a is not obj_b , f" { a_name } and { b_name } are the same object"
266- assert obj_a != obj_b , f" { a_name } == { b_name } but they have different handles"
253+ assert obj_a is not obj_b
254+ assert obj_a != obj_b
267255
268256
269257@pytest .mark .parametrize ("fixture_name,copy_fn" , FROM_HANDLE_COPIES )
270258def test_equality_same_handle (fixture_name , copy_fn , request ):
271259 """Two wrappers around the same handle should compare equal."""
272260 obj = request .getfixturevalue (fixture_name )
273261 obj2 = copy_fn (obj )
274- assert obj == obj2 , f"wrapper equality failed for { type ( obj ). __name__ } "
275- assert hash (obj ) == hash (obj2 ), f"hash equality failed for { type ( obj ). __name__ } "
262+ assert obj == obj2
263+ assert hash (obj ) == hash (obj2 )
276264
277265
278266# =============================================================================
@@ -334,4 +322,4 @@ def test_repr_format(fixture_name, pattern, request):
334322 """repr() returns a properly formatted string."""
335323 obj = request .getfixturevalue (fixture_name )
336324 result = repr (obj )
337- assert re .fullmatch (pattern , result ), f"repr { result !r } does not match { pattern !r } "
325+ assert re .fullmatch (pattern , result )
0 commit comments