Skip to content

Commit

Permalink
Warn about low mock version instead of mock not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed Jan 4, 2013
1 parent 458f48f commit f8073a0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/unit/modules/win_status_test.py
Expand Up @@ -2,8 +2,10 @@
import sys
import os

sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
if __name__ == '__main__':
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
)

from saltunittest import TestCase, TestLoader, TextTestRunner, skipIf

Expand All @@ -16,20 +18,28 @@
sys.modules['pythoncom'] = pythoncom

try:
from mock import Mock, patch, ANY, call
from mock import Mock, patch
has_mock = True

try:
from mock import call, ANY
wrong_version = False
except ImportError:
wrong_version = True
raise
WMI = Mock()
wmi.WMI = Mock(return_value=WMI)
pythoncom.CoInitialize = Mock()
pythoncom.CoUninitialize = Mock()
except ImportError:
has_mock = False


import salt.modules.win_status as status

@skipIf(has_mock is False, "mock python module is unavailable")

@skipIf(has_mock is False,
wrong_version and
"you need to upgrade your mock version to >= 0.8.0" or
"mock python module is unavailable")
class TestProcsBase(TestCase):
def __init__(self, *args, **kwargs):
TestCase.__init__(self, *args, **kwargs)
Expand Down

0 comments on commit f8073a0

Please sign in to comment.