Allow hashing of ErrorDetail to fix #5919 (#5932)

This commit is contained in:
Craig Anderson 2018-04-20 14:32:37 +01:00 committed by Carlton Gibson
parent f148e4e259
commit 2ebd479759
2 changed files with 7 additions and 0 deletions

View File

@ -91,6 +91,9 @@ class ErrorDetail(six.text_type):
self.code, self.code,
)) ))
def __hash__(self):
return hash(str(self))
class APIException(Exception): class APIException(Exception):
""" """

View File

@ -81,6 +81,10 @@ class ErrorDetailTests(TestCase):
assert str(ErrorDetail('msg1')) == 'msg1' assert str(ErrorDetail('msg1')) == 'msg1'
assert str(ErrorDetail('msg1', 'code')) == 'msg1' assert str(ErrorDetail('msg1', 'code')) == 'msg1'
def test_hash(self):
assert hash(ErrorDetail('msg')) == hash('msg')
assert hash(ErrorDetail('msg', 'code')) == hash('msg')
class TranslationTests(TestCase): class TranslationTests(TestCase):