skip vmware inventory when missing lib

fixes #18190
This commit is contained in:
Brian Coca 2016-11-07 15:37:34 -05:00
parent 37de9031c6
commit 8cab33a779

View file

@ -6,13 +6,20 @@ import pickle
import unittest
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
checkout_path = os.path.dirname(__file__)
checkout_path = checkout_path.replace('/test/units/contrib/inventory', '')
inventory_dir = os.path.join(checkout_path, 'contrib', 'inventory')
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
sys.path.remove(os.path.abspath(inventory_dir))