]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: tests: fix mocking of MgrModule and MgrStandbyModule classes
authorRicardo Dias <rdias@suse.com>
Wed, 16 Oct 2019 14:45:11 +0000 (15:45 +0100)
committerRicardo Dias <rdias@suse.com>
Tue, 12 Nov 2019 11:50:51 +0000 (11:50 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/dashboard/conftest.py

index b7fa2d1c29152caaf45f6f00c7fd567089dc5623..8b5e9ac9c36d4c2f4a12a2f0e56a7e3db0c833f8 100644 (file)
@@ -1,9 +1,9 @@
 import sys
 
 try:
-    from mock import Mock
+    from mock import Mock, patch
 except ImportError:
-    from unittest.mock import Mock
+    from unittest.mock import Mock, patch
 
 
 class MockRadosError(Exception):
@@ -24,3 +24,16 @@ def pytest_configure(config):
         'rbd': Mock(),
         'cephfs': Mock(),
     })
+
+    # we need the following patches to fix the issue of multiple inheritance when
+    # one of the base classes is being mocked.
+    # Error example:
+    # TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) \
+    # subclass of the metaclasses of all its bases
+    class _BaseMgrModule:
+        pass
+
+    patcher = patch("ceph_module.BaseMgrStandbyModule", new=_BaseMgrModule)
+    patcher.start()
+    patcher = patch("ceph_module.BaseMgrModule", new=_BaseMgrModule)
+    patcher.start()