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:
parent
bc1ef1ce8f
commit
eb0158c35a
|
@ -13,7 +13,10 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from unittest import mock
|
try:
|
||||||
|
from unittest import mock
|
||||||
|
except ImportError:
|
||||||
|
import mock
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from ansible_runner import Runner
|
from ansible_runner import Runner
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from unittest import mock
|
try:
|
||||||
|
from unittest import mock
|
||||||
|
except ImportError:
|
||||||
|
import mock
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from validations_libs import utils
|
from validations_libs import utils
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from unittest import mock
|
try:
|
||||||
|
from unittest import mock
|
||||||
|
except ImportError:
|
||||||
|
import mock
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from validations_libs.tests import fakes
|
from validations_libs.tests import fakes
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from unittest import mock
|
try:
|
||||||
|
from unittest import mock
|
||||||
|
except ImportError:
|
||||||
|
import mock
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from validations_libs.tests import fakes
|
from validations_libs.tests import fakes
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from unittest import mock
|
try:
|
||||||
|
from unittest import mock
|
||||||
|
except ImportError:
|
||||||
|
import mock
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from validations_libs.tests import fakes
|
from validations_libs.tests import fakes
|
||||||
|
|
Loading…
Reference in New Issue