Skip to content

Commit 418d5a6

Browse files
committed
Merge pull request googleapis#182 from craigcitro/crypto_check
Simplify OpenSSL checks in crypt.py.
2 parents e7340f3 + a687e96 commit 418d5a6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

oauth2client/crypt.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ class AppIdentityError(Exception):
3939

4040

4141
try:
42-
_, _package_dir, _ = imp.find_module('OpenSSL')
43-
if not os.path.isfile(os.path.join(_package_dir, 'crypto.py')):
44-
raise ImportError('No module named OpenSSL')
42+
_ = imp.find_module('OpenSSL')
4543

4644
class OpenSSLVerifier(object):
4745
"""Verifies the signature on a message."""

tests/test_crypt.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ def test_succeeds(self):
5858
self.assertTrue(pem_contents in [pkcs12_key_as_pem, alternate_pem])
5959

6060
def test_without_openssl(self):
61-
import os
62-
path_isfile = os.path.isfile
61+
import imp
62+
imp_find_module = imp.find_module
63+
def find_module(module_name):
64+
raise ImportError('No module named %s' % module_name)
6365
try:
64-
os.path.isfile = lambda value: False
66+
imp.find_module = find_module
6567
reload(crypt)
6668
self.assertRaises(NotImplementedError, crypt.pkcs12_key_as_pem,
6769
'FOO', 'BAR')
6870
finally:
69-
os.path.isfile = path_isfile
71+
imp.find_module = imp_find_module
7072
reload(crypt)
7173

7274
def test_with_nonsense_key(self):

0 commit comments

Comments
 (0)