Fix mod_random test on older distros

This commit is contained in:
Mike Place 2015-02-10 08:46:42 -07:00
parent f232f7f9fe
commit f8aeef25fc
2 changed files with 18 additions and 0 deletions

View File

@ -20,6 +20,10 @@ def __virtual__():
'''
Confirm this module is on a Debian based system
'''
# Certain versions of hashlib do not contain
# the necessary functions
if not hasattr(hashlib, 'algorithms'):
return False
return __virtualname__

View File

@ -29,6 +29,20 @@ mod_random.__context__ = {}
mod_random.__opts__ = {}
def _test_hashlib():
try:
import hashlib
except ImportError:
return False
if not hasattr(hashlib, 'algorithms'):
return False
else:
return True
SUPPORTED_HASHLIB = _test_hashlib()
@skipIf(not SUPPORTED_HASHLIB, 'Hashlib does not contain needed functionality')
@skipIf(NO_MOCK, NO_MOCK_REASON)
class ModrandomTestCase(TestCase):
'''