From: Sebastian Wagner Date: Wed, 26 Aug 2020 08:39:20 +0000 (+0200) Subject: pybind/mgr: pytest: Unconditionally mock the rados objects X-Git-Tag: wip-pdonnell-testing-20200918.022351~247^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4cc50496b4ac5f3807414efaa7e9493186eed1f1;p=ceph-ci.git pybind/mgr: pytest: Unconditionally mock the rados objects Always call `mock_ceph_modules()`. Otherwise we'd need to split the tox run between modules that need to call `mock_ceph_modules()` and those that don't Fixes: https://tracker.ceph.com/issues/47141 Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/cephadm/__init__.py b/src/pybind/mgr/cephadm/__init__.py index 9a9f0743211..f390f18c16a 100644 --- a/src/pybind/mgr/cephadm/__init__.py +++ b/src/pybind/mgr/cephadm/__init__.py @@ -2,6 +2,5 @@ import os if 'UNITTEST' in os.environ: import tests - tests.mock_ceph_modules() # type: ignore from .module import CephadmOrchestrator diff --git a/src/pybind/mgr/dashboard/__init__.py b/src/pybind/mgr/dashboard/__init__.py index 30013bb7771..548d401238f 100644 --- a/src/pybind/mgr/dashboard/__init__.py +++ b/src/pybind/mgr/dashboard/__init__.py @@ -38,12 +38,10 @@ else: os.environ['PATH'] = '{}:{}'.format(os.path.abspath('../../../../build/bin'), os.environ['PATH']) - from tests import mock, mock_ceph_modules # type: ignore + from tests import mock # type: ignore mgr = mock.Mock() mgr.get_frontend_path.side_effect = lambda: os.path.abspath("./frontend/dist") - mock_ceph_modules() - # DO NOT REMOVE: required for ceph-mgr to load a module from .module import Module, StandbyModule # noqa: F401 diff --git a/src/pybind/mgr/mds_autoscaler/__init__.py b/src/pybind/mgr/mds_autoscaler/__init__.py index 85a3241266b..326792113f8 100644 --- a/src/pybind/mgr/mds_autoscaler/__init__.py +++ b/src/pybind/mgr/mds_autoscaler/__init__.py @@ -2,6 +2,5 @@ import os if 'UNITTEST' in os.environ: import tests - tests.mock_ceph_modules() # type: ignore from .module import MDSAutoscaler diff --git a/src/pybind/mgr/tests/__init__.py b/src/pybind/mgr/tests/__init__.py index 7b6fb41b225..26354dc2cf5 100644 --- a/src/pybind/mgr/tests/__init__.py +++ b/src/pybind/mgr/tests/__init__.py @@ -189,4 +189,7 @@ if 'UNITTEST' in os.environ: 'rados': mock.MagicMock(Error=MockRadosError, OSError=MockRadosError), 'rbd': mock.Mock(), 'cephfs': mock.Mock(), - }) \ No newline at end of file + }) + + # Unconditionally mock the rados objects when we're imported + mock_ceph_modules() # type: ignore