Skip to content

Commit

Permalink
Merge pull request #2595 from alex/crl-reason-hash
Browse files Browse the repository at this point in the history
Refs #2578 -- implement __hash__ on CRLReason
  • Loading branch information
reaperhulk committed Dec 27, 2015
2 parents b25888d + 07d5cae commit 58fb257
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cryptography/x509/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,9 @@ def __eq__(self, other):
def __ne__(self, other):
return not self == other

def __hash__(self):
return hash(self.reason)

reason = utils.read_only_property("_reason")


Expand Down
8 changes: 8 additions & 0 deletions tests/test_x509_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ def test_ne(self):
assert reason1 != reason2
assert reason1 != object()

def test_hash(self):
reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
reason2 = x509.CRLReason(x509.ReasonFlags.unspecified)
reason3 = x509.CRLReason(x509.ReasonFlags.ca_compromise)

assert hash(reason1) == hash(reason2)
assert hash(reason1) != hash(reason3)

def test_repr(self):
reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
assert repr(reason1) == (
Expand Down

0 comments on commit 58fb257

Please sign in to comment.