Allow hashing of ErrorDetail to fix #5919

This commit is contained in:
Craig Anderson 2018-04-11 14:44:38 +01:00
parent 1c53fd3212
commit 4d126835af
2 changed files with 7 additions and 0 deletions

View File

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

View File

@ -81,6 +81,10 @@ class ErrorDetailTests(TestCase):
assert str(ErrorDetail('msg1')) == '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):