From: John Mulligan Date: Mon, 26 Sep 2022 15:19:48 +0000 (-0400) Subject: cephadm: use a function to encapsulate loading cephadm as a module X-Git-Tag: v18.1.0~1104^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1c6f1eb598246f0bb60ee5ed6608ba29d0c2981f;p=ceph.git cephadm: use a function to encapsulate loading cephadm as a module Instead of "open coding" all the cephadm imports let's do it in a reusable function. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/tests/fixtures.py b/src/cephadm/tests/fixtures.py index 3ec1d165d836..02f7eeb5d197 100644 --- a/src/cephadm/tests/fixtures.py +++ b/src/cephadm/tests/fixtures.py @@ -10,9 +10,17 @@ from pyfakefs import fake_filesystem from typing import Callable, Dict, List, Optional -with mock.patch('builtins.open', create=True): - from importlib.machinery import SourceFileLoader - cd = SourceFileLoader('cephadm', 'cephadm.py').load_module() +def import_cephadm(): + """Import cephadm as a module. + """ + with mock.patch('builtins.open', create=True): + from importlib.machinery import SourceFileLoader + + cd = SourceFileLoader('cephadm', 'cephadm.py').load_module() + return cd + + +cd = import_cephadm() def mock_docker():