Skip to content

Commit

Permalink
Refs pyca#2578 -- implement __hash__ on CRLNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Dec 26, 2015
1 parent d67d77f commit f9a77b6
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -132,6 +132,9 @@ def __eq__(self, other):
def __ne__(self, other):
return not self == other

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

def __repr__(self):
return "<CRLNumber({0})>".format(self.crl_number)

Expand Down
7 changes: 7 additions & 0 deletions tests/test_x509_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,13 @@ def test_invalid_number(self):
with pytest.raises(TypeError):
x509.CRLNumber("notanumber")

def test_hash(self):
c1 = x509.CRLNumber(1)
c2 = x509.CRLNumber(1)
c3 = x509.CRLNumber(2)
assert hash(c1) == hash(c2)
assert hash(c1) != hash(c3)


class TestSubjectAlternativeName(object):
def test_get_values_for_type(self):
Expand Down

0 comments on commit f9a77b6

Please sign in to comment.