@@ -54,7 +54,7 @@ def test_fuzz(self, key_type: type):
54
54
"__len__" , "__lt__" , "__ne__" , "__reduce__" , "__reduce_ex__" , "__repr__" , "__setattr__" , "__sizeof__" ,
55
55
"__str__" , "__subclasshook__" , "__weakref__" , "items" , "key_type" , "values" ,
56
56
)) # fmt: skip
57
- for attr in self ._rg .choices ([* attrs ], k = 50_000 ):
57
+ for attr in self ._rg .choices ([* attrs ], k = 10_000 ):
58
58
getattr (self , f"_test_{ attr } " )()
59
59
60
60
with pytest .raises (TypeError , match = "^unhashable type: 'pysorteddict.SortedDict'$" ):
@@ -71,26 +71,27 @@ def test_fuzz(self, key_type: type):
71
71
assert self .sorted_dict .values () == [* sorted_normal_dict .values ()]
72
72
73
73
def _test___contains__ (self ):
74
- for key_type in all_types :
75
- key = self ._gen (key_type )
76
- if self .is_sorted_dict_new :
77
- with pytest .raises (RuntimeError , match = "^key type not set: insert at least one item first$" ):
78
- key in self .sorted_dict # noqa: B015
79
- continue
80
- if key_type is not self .key_type :
81
- with pytest .raises (
82
- TypeError ,
83
- match = re .escape (f"got key { key !r} of type { key_type !r} , want key of type { self .key_type !r} " ),
84
- ):
85
- key in self .sorted_dict # noqa: B015
86
- continue
87
- if (key_type is float or key_type is decimal .Decimal ) and math .isnan (key ):
88
- with pytest .raises (ValueError , match = re .escape (f"got bad key { key !r} of type { key_type !r} " )):
89
- key in self .sorted_dict # noqa: B015
90
- continue
91
- if self .normal_dict :
92
- assert self ._rg .choice ([* self .normal_dict ]) in self .sorted_dict
93
- assert (key in self .sorted_dict ) == (key in self .normal_dict )
74
+ for sorted_dict_or_sorted_dict_keys in (self .sorted_dict , self .sorted_dict_keys ):
75
+ for key_type in all_types :
76
+ key = self ._gen (key_type )
77
+ if self .is_sorted_dict_new :
78
+ with pytest .raises (RuntimeError , match = "^key type not set: insert at least one item first$" ):
79
+ key in sorted_dict_or_sorted_dict_keys # noqa: B015
80
+ continue
81
+ if key_type is not self .key_type :
82
+ with pytest .raises (
83
+ TypeError ,
84
+ match = re .escape (f"got key { key !r} of type { key_type !r} , want key of type { self .key_type !r} " ),
85
+ ):
86
+ key in sorted_dict_or_sorted_dict_keys # noqa: B015
87
+ continue
88
+ if (key_type is float or key_type is decimal .Decimal ) and math .isnan (key ):
89
+ with pytest .raises (ValueError , match = re .escape (f"got bad key { key !r} of type { key_type !r} " )):
90
+ key in sorted_dict_or_sorted_dict_keys # noqa: B015
91
+ continue
92
+ if self .normal_dict :
93
+ assert self ._rg .choice ([* self .normal_dict ]) in sorted_dict_or_sorted_dict_keys
94
+ assert (key in sorted_dict_or_sorted_dict_keys ) == (key in self .normal_dict )
94
95
95
96
def _test___delattr__ (self ):
96
97
with pytest .raises (AttributeError ):
0 commit comments