]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use a function to encapsulate loading cephadm as a module
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 26 Sep 2022 15:19:48 +0000 (11:19 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 27 Sep 2022 18:41:54 +0000 (14:41 -0400)
Instead of "open coding" all the cephadm imports let's do it in a
reusable function.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/fixtures.py

index 3ec1d165d836442b84acb4653d173523c3cbaa1d..02f7eeb5d1973804affea3431cce70e0ce5c23b2 100644 (file)
@@ -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():