aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-12-26 12:14:25 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2015-12-26 12:14:25 -0500
commitf9a77b6886ac8942645a24b8cb65479fcfd23d09 (patch)
tree8a5bcc2b0f9f187ec8f4384e483c972feac053e4
parentd67d77f666417bff7ea52e2754f7a680c7a83b0c (diff)
downloadcryptography-f9a77b6886ac8942645a24b8cb65479fcfd23d09.tar.gz
cryptography-f9a77b6886ac8942645a24b8cb65479fcfd23d09.tar.bz2
cryptography-f9a77b6886ac8942645a24b8cb65479fcfd23d09.zip
Refs #2578 -- implement __hash__ on CRLNumber
-rw-r--r--src/cryptography/x509/extensions.py3
-rw-r--r--tests/test_x509_ext.py7
2 files changed, 10 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 6ae00927..2363d2bf 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -132,6 +132,9 @@ class CRLNumber(object):
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)
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index b8105a4b..49a3433c 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -1579,6 +1579,13 @@ class TestCRLNumber(object):
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):