From: John Mulligan Date: Fri, 1 Nov 2024 15:41:33 +0000 (-0400) Subject: mgr/cephadm: fix invalid use of mock called_with method X-Git-Tag: v20.0.0~647^2~25 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8726e214fb7d8e34fe2d61f044f8aa707be66081;p=ceph.git mgr/cephadm: fix invalid use of mock called_with method Fixes `AttributeError: 'called_with' is not a valid assertion` errors that appear when running the unit tests with python3.12. Part of an effort to get ceph tox environments passing on Python 3.12. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 6d0c00d408c..41364a8acb1 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -499,7 +499,7 @@ class TestCephadm(object): CephadmServe(cephadm_module)._check_daemons() - assert _save_host.called_with('test') + _save_host.assert_called_with('test') assert cephadm_module.cache.get_scheduled_daemon_action('test', daemon_name) is None @mock.patch("cephadm.serve.CephadmServe._run_cephadm") @@ -2849,15 +2849,15 @@ Traceback (most recent call last): # pass force=true in these tests to bypass _admin label check with with_host(cephadm_module, 'test', refresh_hosts=False, rm_with_force=True): cephadm_module.drain_host('test', force=True, zap_osd_devices=False) - assert _rm_osds.called_with([], zap=False) + _rm_osds.assert_called_with([], zap=False) with with_host(cephadm_module, 'test', refresh_hosts=False, rm_with_force=True): cephadm_module.drain_host('test', force=True, zap_osd_devices=True) - assert _rm_osds.called_with([], zap=True) + _rm_osds.assert_called_with([], zap=True) with pytest.raises(OrchestratorError, match=r"Cannot find host 'host1' in the inventory."): cephadm_module.drain_host('host1', force=True, zap_osd_devices=True) - assert _rm_osds.called_with([], zap=True) + _rm_osds.assert_called_with([], zap=True) def test_process_ls_output(self, cephadm_module): sample_ls_output = """[