From 0a0293e535c8bfd1cf329f77b51d31400aadd5d1 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Mon, 1 Feb 2016 12:56:40 -0330 Subject: [PATCH] Refs #2578 -- implement __hash__ on InhibitAnyPolicy --- src/cryptography/x509/extensions.py | 3 +++ tests/test_x509_ext.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index fe9bcf9b772f..db55789ef111 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -693,6 +693,9 @@ def __eq__(self, other): def __ne__(self, other): return not self == other + def __hash__(self): + return hash(self.skip_certs) + skip_certs = utils.read_only_property("_skip_certs") diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index b13405de4de8..d8a5f9de814f 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -3398,6 +3398,13 @@ def test_ne(self): assert iap != iap2 assert iap != object() + def test_hash(self): + iap = x509.InhibitAnyPolicy(1) + iap2 = x509.InhibitAnyPolicy(1) + iap3 = x509.InhibitAnyPolicy(4) + assert hash(iap) == hash(iap2) + assert hash(iap) != hash(iap3) + @pytest.mark.requires_backend_interface(interface=RSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend)