Fix tests to prevent errors when libcloud is not present

This commit is contained in:
Pablo Suárez Hernández 2016-09-06 12:44:36 +01:00
parent 71ebf2c8cd
commit 1c260e4bd0
2 changed files with 16 additions and 4 deletions

View file

@ -8,7 +8,13 @@
# Import Python libs
from __future__ import absolute_import
import libcloud.security
try:
import libcloud.security
HAS_LIBCLOUD = True
except ImportError:
HAS_LIBCLOUD = False
import platform
import os
@ -44,7 +50,7 @@ ON_SUSE = True if 'SuSE' in platform.dist() else False
ON_MAC = True if 'Darwin' in platform.system() else False
if not os.path.exists('/etc/ssl/certs/YaST-CA.pem') and ON_SUSE:
if os.path.isfile('/etc/ssl/ca-bundle.pem'):
if os.path.isfile('/etc/ssl/ca-bundle.pem') and HAS_LIBCLOUD:
libcloud.security.CA_CERTS_PATH.append('/etc/ssl/ca-bundle.pem')
else:
HAS_CERTS = False

View file

@ -8,7 +8,13 @@
# Import Python libs
from __future__ import absolute_import
import libcloud.security
try:
import libcloud.security
HAS_LIBCLOUD = True
except ImportError:
HAS_LIBCLOUD = False
import platform
import os
@ -51,7 +57,7 @@ ON_SUSE = True if 'SuSE' in platform.dist() else False
ON_MAC = True if 'Darwin' in platform.system() else False
if not os.path.exists('/etc/ssl/certs/YaST-CA.pem') and ON_SUSE:
if os.path.isfile('/etc/ssl/ca-bundle.pem'):
if os.path.isfile('/etc/ssl/ca-bundle.pem') and HAS_LIBCLOUD:
libcloud.security.CA_CERTS_PATH.append('/etc/ssl/ca-bundle.pem')
else:
HAS_CERTS = False