From: John Mulligan Date: Mon, 26 Sep 2022 19:20:25 +0000 (-0400) Subject: cephadm: remove container_engine argument from test helper function X-Git-Tag: v18.1.0~1104^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf963d5ac41274b8a612abd22c0516d5db9d9a37;p=ceph.git cephadm: remove container_engine argument from test helper function The with_cephadm_ctx test helper function had an argument that *called* mock_podman function, thus calling the function at import-time. This can lead to confusing and unexpected side effects. Because the container_engine argument is not used by any callers of with_cephadm_ctx we remove the argument. All other callers of with_cephadm_ctx that make use of container engine are already setting `ctx.container_engine = ` so removing the argument makes it harder to make the same mistake again in the future. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/tests/fixtures.py b/src/cephadm/tests/fixtures.py index 02f7eeb5d19..58903d15902 100644 --- a/src/cephadm/tests/fixtures.py +++ b/src/cephadm/tests/fixtures.py @@ -7,7 +7,7 @@ import time from contextlib import contextmanager from pyfakefs import fake_filesystem -from typing import Callable, Dict, List, Optional +from typing import Dict, List, Optional def import_cephadm(): @@ -117,13 +117,11 @@ def host_sysfs(fs: fake_filesystem.FakeFilesystem): @contextmanager def with_cephadm_ctx( cmd: List[str], - container_engine: Callable = mock_podman(), list_networks: Optional[Dict[str,Dict[str,List[str]]]] = None, hostname: Optional[str] = None, ): """ :param cmd: cephadm command argv - :param container_engine: container engine mock (podman or docker) :param list_networks: mock 'list-networks' return :param hostname: mock 'socket.gethostname' return """ @@ -140,7 +138,7 @@ def with_cephadm_ctx( mock.patch('cephadm.logger'), \ mock.patch('socket.gethostname', return_value=hostname): ctx: cd.CephadmContext = cd.cephadm_init_ctx(cmd) - ctx.container_engine = container_engine + ctx.container_engine = mock_podman() if list_networks is not None: with mock.patch('cephadm.list_networks', return_value=list_networks): yield ctx