Gate: fix AttributeError: load_pem_x509_csr

Gate picks cryptography 1.3 version, for x509, it is
_ModuleWithDeprecations instead of a module, see
https://github.com/pyca/cryptography/issues/2844 .

So that will bring trouble when an mocked object __exit__().

This fix is only works for v1.3 cryptography (on gate).

Closes-Bug: #1559845
Change-Id: I852e6c5bf4c16b234ba92b2449c09b991fa6c5a0
This commit is contained in:
Eli Qiao 2016-03-21 17:28:21 +08:00
parent ddb7eeaab3
commit a75b5fb77a
1 changed files with 3 additions and 1 deletions

View File

@ -183,7 +183,9 @@ class TestX509(base.BaseTestCase):
self.assertInClientExtensions(cert)
@mock.patch('cryptography.x509.load_pem_x509_csr')
# Notes(eliqiao): Remove this '_module' after cryptography issue fixed
# https://github.com/pyca/cryptography/issues/2844
@mock.patch('cryptography.x509._module.load_pem_x509_csr')
@mock.patch('six.b')
def test_sign_with_unicode_csr(self, mock_six, mock_load_pem):
ca_key = self._generate_private_key()