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
This commit is contained in:
Mathieu Bultel 2020-04-01 15:54:28 +02:00
parent bc1ef1ce8f
commit eb0158c35a
5 changed files with 20 additions and 5 deletions

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

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

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

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

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