From 3a23930bb6a1802c01179e871d669c37ebfac029 Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 16 Dec 2021 09:26:42 +0000 Subject: [PATCH] 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 --- .zuul.yaml | 2 +- osci.yaml | 5 ++--- test-requirements.txt | 1 - tox.ini | 5 +++++ unit_tests/__init__.py | 2 +- unit_tests/test_ceph_dashboard_charm.py | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index fd20909..0eed196 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,4 +1,4 @@ - project: templates: - - openstack-python3-charm-jobs + - openstack-python3-ussuri-jobs - openstack-cover-jobs diff --git a/osci.yaml b/osci.yaml index 46cf1ec..2088973 100644 --- a/osci.yaml +++ b/osci.yaml @@ -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: diff --git a/test-requirements.txt b/test-requirements.txt index fb837fb..90c3691 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index 4ca4d73..79ddb1a 100644 --- a/tox.ini +++ b/tox.ini @@ -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 diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index adce0b6..59620d3 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -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() diff --git a/unit_tests/test_ceph_dashboard_charm.py b/unit_tests/test_ceph_dashboard_charm.py index b58825f..5542120 100644 --- a/unit_tests/test_ceph_dashboard_charm.py +++ b/unit_tests/test_ceph_dashboard_charm.py @@ -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 (