def test_optional_types(): DT = Dict() DT2 = Dict(Signed, Float) assert DT != Signed assert DT != DT2 assert DT2 != DT py.test.raises(TypeError, hash, DT) setDictTypes(DT, Signed, Float) assert DT == DT2 assert DT2 == DT assert hash(DT) == hash(DT2)
def _setup_repr(self): if 'key_repr' not in self.__dict__: key_repr = self._key_repr_computer() self.external_key_repr, self.key_repr = self.pickkeyrepr(key_repr) if 'value_repr' not in self.__dict__: self.external_value_repr, self.value_repr = self.pickrepr(self._value_repr_computer()) if not ootype.hasDictTypes(self.DICT): ootype.setDictTypes(self.DICT, self.key_repr.lowleveltype, self.value_repr.lowleveltype) if self.custom_eq_hash: self.r_rdict_eqfn, self.r_rdict_hashfn = self._custom_eq_hash_repr()
def _setup_repr(self): if 'key_repr' not in self.__dict__: key_repr = self._key_repr_computer() self.external_key_repr, self.key_repr = self.pickkeyrepr(key_repr) if 'value_repr' not in self.__dict__: self.external_value_repr, self.value_repr = self.pickrepr( self._value_repr_computer()) if not ootype.hasDictTypes(self.DICT): ootype.setDictTypes(self.DICT, self.key_repr.lowleveltype, self.value_repr.lowleveltype) if self.custom_eq_hash: self.r_rdict_eqfn, self.r_rdict_hashfn = self._custom_eq_hash_repr( )
def test_recursive_str_hash(): DT = Dict() setDictTypes(DT, Signed, DT) assert isinstance(str(DT), str) assert isinstance(hash(DT), int)