diff --git a/tests/unit/modules/gem_test.py b/tests/unit/modules/gem_test.py index d18df7ca14..2dda7fbba5 100644 --- a/tests/unit/modules/gem_test.py +++ b/tests/unit/modules/gem_test.py @@ -3,13 +3,18 @@ import os sys.path.insert( 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) -from saltunittest import TestCase, TestLoader, TextTestRunner -from mock import MagicMock, patch +from saltunittest import TestCase, TestLoader, TextTestRunner, skipIf +try: + from mock import MagicMock, patch + has_mock = True +except ImportError: + has_mock = False import salt.modules.gem as gem gem.__salt__ = {} +@skipIf(has_mock is False, "mock python module is unavailable") class TestGemModule(TestCase): def test__gem(self): diff --git a/tests/unit/modules/rvm_test.py b/tests/unit/modules/rvm_test.py index e10401591e..b27a506bb9 100644 --- a/tests/unit/modules/rvm_test.py +++ b/tests/unit/modules/rvm_test.py @@ -3,14 +3,20 @@ import os sys.path.insert( 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) -from saltunittest import TestCase, TestLoader, TextTestRunner -from mock import MagicMock, patch +from saltunittest import TestCase, TestLoader, TextTestRunner, skipIf +try: + from mock import MagicMock, patch + has_mock = True +except ImportError: + has_mock = False -import salt.modules.rvm as rvm -rvm.__salt__ = { - 'cmd.has_exec': MagicMock(return_value=True)} +if has_mock: + import salt.modules.rvm as rvm + rvm.__salt__ = { + 'cmd.has_exec': MagicMock(return_value=True)} +@skipIf(has_mock is False, "mock python module is unavailable") class TestRvmModule(TestCase): def test__rvm(self): diff --git a/tests/unit/states/gem_test.py b/tests/unit/states/gem_test.py index 298b837f09..1e8e1746b0 100644 --- a/tests/unit/states/gem_test.py +++ b/tests/unit/states/gem_test.py @@ -3,14 +3,19 @@ import os sys.path.insert( 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) -from saltunittest import TestCase, TestLoader, TextTestRunner -from mock import MagicMock, patch +from saltunittest import TestCase, TestLoader, TextTestRunner, skipIf +try: + from mock import MagicMock, patch + has_mock = True +except ImportError: + has_mock = False import salt.states.gem as gem gem.__salt__ = {} gem.__opts__ = {'test': False} +@skipIf(has_mock is False, "mock python module is unavailable") class TestGemState(TestCase): def test_installed(self): diff --git a/tests/unit/states/rvm_test.py b/tests/unit/states/rvm_test.py index 0b2792dd4f..487c69b04b 100644 --- a/tests/unit/states/rvm_test.py +++ b/tests/unit/states/rvm_test.py @@ -3,14 +3,19 @@ import os sys.path.insert( 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) -from saltunittest import TestCase, TestLoader, TextTestRunner -from mock import MagicMock, patch +from saltunittest import TestCase, TestLoader, TextTestRunner, skipIf +try: + from mock import MagicMock, patch + has_mock = True +except ImportError: + has_mock = False import salt.states.rvm as rvm rvm.__salt__ = {} rvm.__opts__ = {'test': False} +@skipIf(has_mock is False, "mock python module is unavailable") class TestRvmState(TestCase): def test__check_rvm(self):