skip vmware inventory when missing lib

fixes #18190
pull/18409/head
Brian Coca 8 years ago
parent 37de9031c6
commit 8cab33a779

@ -6,13 +6,20 @@ import pickle
import unittest import unittest
import sys import sys
try:
from vmware_inventory import VMWareInventory
except ImportError:
from nose.plugins.skip import SkipTest
raise SkipTest("test_vmware_inventory.py requires the python module 'vmware_inventory'")
# contrib's dirstruct doesn't contain __init__.py files # contrib's dirstruct doesn't contain __init__.py files
checkout_path = os.path.dirname(__file__) checkout_path = os.path.dirname(__file__)
checkout_path = checkout_path.replace('/test/units/contrib/inventory', '') checkout_path = checkout_path.replace('/test/units/contrib/inventory', '')
inventory_dir = os.path.join(checkout_path, 'contrib', 'inventory') inventory_dir = os.path.join(checkout_path, 'contrib', 'inventory')
sys.path.append(os.path.abspath(inventory_dir)) sys.path.append(os.path.abspath(inventory_dir))
from vmware_inventory import VMWareInventory
# cleanup so that nose's path is not polluted with other inv scripts # cleanup so that nose's path is not polluted with other inv scripts
sys.path.remove(os.path.abspath(inventory_dir)) sys.path.remove(os.path.abspath(inventory_dir))

Loading…
Cancel
Save