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.

Change-Id: If62bed2598c42b861a11ceab21e9f1ab0c0cf9dd
This commit is contained in:
James Page 2021-12-16 09:26:42 +00:00
parent f59a409c01
commit 3a23930bb6
6 changed files with 10 additions and 7 deletions

View File

@ -1,4 +1,4 @@
- project:
templates:
- openstack-python3-charm-jobs
- openstack-python3-ussuri-jobs
- openstack-cover-jobs

View File

@ -1,6 +1,6 @@
- project:
templates:
- charm-unit-jobs
- charm-yoga-unit-jobs
check:
jobs:
- bionic-octopus
@ -15,10 +15,9 @@
parent: func-target
dependencies:
- osci-lint
- tox-py35
- tox-py36
- tox-py37
- tox-py38
- tox-py39
vars:
tox_extra_args: focal
- job:

View File

@ -3,7 +3,6 @@
# requirements management in charms via bot-control. Thank you.
charm-tools>=2.4.4
coverage>=3.6
mock>=1.2
flake8>=2.2.4,<=2.4.1
pyflakes==2.1.1
stestr>=2.2.0

View File

@ -57,6 +57,11 @@ basepython = python3.8
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:py39]
basepython = python3.9
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:py3]
basepython = python3
deps = -r{toxinidir}/requirements.txt

View File

@ -13,7 +13,7 @@
# limitations under the License.
import sys
import mock
import unittest.mock as mock
# Mock out secrets to make py35 happy.
sys.modules['secrets'] = mock.MagicMock()

View File

@ -22,7 +22,7 @@ import sys
sys.path.append('lib') # noqa
sys.path.append('src') # noqa
from mock import ANY, call, patch, MagicMock
from unittest.mock import ANY, call, patch, MagicMock
from ops.testing import Harness, _TestingModelBackend
from ops.model import (