Browse Source

Make mock import python 2.7 compatible

In python3.x mock is now part of unittest library.
For being still compatible with python 2.7 we need to
catch import error when trying to import unittest.mock

Change-Id: I6aca21bea4f1563e1f3c5ecfb91c511191eb409b
changes/97/716597/1
Mathieu Bultel 1 year ago
parent
commit
eb0158c35a
5 changed files with 20 additions and 5 deletions
  1. +4
    -1
      validations_libs/tests/test_ansible.py
  2. +4
    -1
      validations_libs/tests/test_utils.py
  3. +4
    -1
      validations_libs/tests/test_validations_list.py
  4. +4
    -1
      validations_libs/tests/test_validations_run.py
  5. +4
    -1
      validations_libs/tests/test_validations_show.py

+ 4
- 1
validations_libs/tests/test_ansible.py View File

@ -13,7 +13,10 @@
# under the License.
#
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
from unittest import TestCase
from ansible_runner import Runner


+ 4
- 1
validations_libs/tests/test_utils.py View File

@ -13,7 +13,10 @@
# under the License.
#
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
from unittest import TestCase
from validations_libs import utils


+ 4
- 1
validations_libs/tests/test_validations_list.py View File

@ -13,7 +13,10 @@
# under the License.
#
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
from unittest import TestCase
from validations_libs.tests import fakes


+ 4
- 1
validations_libs/tests/test_validations_run.py View File

@ -13,7 +13,10 @@
# under the License.
#
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
from unittest import TestCase
from validations_libs.tests import fakes


+ 4
- 1
validations_libs/tests/test_validations_show.py View File

@ -13,7 +13,10 @@
# under the License.
#
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
from unittest import TestCase
from validations_libs.tests import fakes


Loading…
Cancel
Save