Permalink
Browse files

Warn about low mock version instead of mock not available.

  • Loading branch information...
s0undt3ch committed Jan 4, 2013
1 parent 458f48f commit f8073a08ebcd82c308add8ae70d4f7e159bb95f8
Showing with 16 additions and 6 deletions.
  1. +16 −6 tests/unit/modules/win_status_test.py
@@ -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
@@ -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)

0 comments on commit f8073a0

Please sign in to comment.