diff --git a/tests/test_base.py b/tests/test_base.py index dbbbd15..95fbcb9 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import pytest + import thriftpy from thriftpy.thrift import parse_spec, TType @@ -28,10 +30,11 @@ def test_isinstancecheck(): assert isinstance(ab.PersonNotExistsError(), ab2.PersonNotExistsError) -def test_hashable(): +def test_unhashable(): ab = thriftpy.load("addressbook.thrift") - hash(ab.Person(name="Tom")) + with pytest.raises(TypeError): + hash(ab.Person(name="Tom")) def test_default_value(): diff --git a/thriftpy/thrift.py b/thriftpy/thrift.py index 1bb87f9..6538d6c 100644 --- a/thriftpy/thrift.py +++ b/thriftpy/thrift.py @@ -122,7 +122,7 @@ def __eq__(self, other): self.__dict__ == other.__dict__ def __hash__(self): - return super(TPayload, self).__hash__() + raise TypeError("unhashable type: 'thriftpy.thrift.TPayload'") def __ne__(self, other): return not self.__eq__(other)