Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2 runtimes. Since we now only support py36 and later, we can use the standard lib unittest.mock module instead. Note that https://github.com/openstack/charms.openstack is used during tests and he need `mock`, unfortunatelly it doesn't declare `mock` in its requirements so it retrieve mock from other charm project (cross dependency). So we depend on charms.openstack first and when Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI will pass without errors. Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142 Change-Id: Ib658c7f61fe4aceafc1919e366d24ce81ec1dd63
This commit is contained in:
parent
313e71bc7b
commit
4cbac58ba1
@ -1,4 +1,4 @@
|
||||
- project:
|
||||
templates:
|
||||
- openstack-python3-charm-jobs
|
||||
- openstack-python3-ussuri-jobs
|
||||
- openstack-cover-jobs
|
||||
|
@ -13,11 +13,7 @@ setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb
|
||||
|
||||
requests>=2.18.4
|
||||
|
||||
# Newer mock seems to have some syntax which is newer than python3.5 (e.g.
|
||||
# f'{something}'
|
||||
mock>=1.2,<4.0.0; python_version < '3.6'
|
||||
mock>=1.2; python_version >= '3.6'
|
||||
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
stestr>=2.2.0
|
||||
|
||||
# Dependency of stestr. Workaround for
|
||||
|
@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
from actions import add_disk
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
from charmhelpers.core import hookenv
|
||||
|
||||
|
@ -11,11 +11,12 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import mock
|
||||
import subprocess
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from test_utils import CharmTestCase
|
||||
|
||||
sys.path.append('hooks')
|
||||
|
@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
import unittest.mock as mock
|
||||
from contextlib import contextmanager
|
||||
|
||||
from actions import service
|
||||
|
@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
from actions import zap_disk
|
||||
|
||||
|
@ -17,7 +17,7 @@ from collections import OrderedDict
|
||||
import copy
|
||||
import unittest
|
||||
|
||||
from mock import patch, MagicMock, call
|
||||
from unittest.mock import patch, MagicMock, call
|
||||
|
||||
import charmhelpers.contrib.storage.linux.ceph as ceph
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import unittest
|
||||
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
with patch('charmhelpers.contrib.hardening.harden.harden') as mock_dec:
|
||||
mock_dec.side_effect = (lambda *dargs, **dkwargs: lambda f:
|
||||
|
@ -18,7 +18,7 @@ import tempfile
|
||||
import sys
|
||||
import test_utils
|
||||
|
||||
from mock import patch, MagicMock
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
# python-apt is not installed as part of test-requirements but is imported by
|
||||
# some charmhelpers modules so create a fake import.
|
||||
|
@ -12,10 +12,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
import test_utils
|
||||
|
||||
from mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
with patch('charmhelpers.contrib.hardening.harden.harden') as mock_dec:
|
||||
mock_dec.side_effect = (lambda *dargs, **dkwargs: lambda f:
|
||||
|
@ -1,5 +1,5 @@
|
||||
__author__ = 'Chris Holcombe <chris.holcombe@canonical.com>'
|
||||
from mock import patch, call
|
||||
from unittest.mock import patch, call
|
||||
import test_utils
|
||||
import charms_ceph.utils as ceph
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from mock import call, patch
|
||||
from unittest.mock import call, patch
|
||||
from test_utils import CharmTestCase
|
||||
from ceph_hooks import check_for_upgrade, notify_mon_of_upgrade
|
||||
|
||||
|
@ -19,7 +19,7 @@ import sys
|
||||
import yaml
|
||||
|
||||
from contextlib import contextmanager
|
||||
from mock import patch, MagicMock
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
# python-apt is not installed as part of test-requirements but is imported by
|
||||
# some charmhelpers modules so create a fake import.
|
||||
|
Loading…
x
Reference in New Issue
Block a user