From 0a882a736c957ff2f638aa3bb113ae1f8074ef65 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 1 Jun 2023 11:16:13 -0400 Subject: [PATCH] cephadm: change tests to assert using mock call not func.args The Python docs [1] note that: Changed in version 3.8: Added args and kwargs properties. In order to run tests on python 3.6 (example: `tox -e py36`) we change the tests to do the asserts using the older call(...) comparison style, with mock.ANY used for args we don't care about. [1] - https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.call_args Signed-off-by: John Mulligan --- src/cephadm/tests/test_util_funcs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cephadm/tests/test_util_funcs.py b/src/cephadm/tests/test_util_funcs.py index f29c0819fb570..ea79c0877a9ad 100644 --- a/src/cephadm/tests/test_util_funcs.py +++ b/src/cephadm/tests/test_util_funcs.py @@ -94,7 +94,7 @@ class TestCopyTree: self._copy_tree([src1], dst, uid=0, gid=0) assert len(_chown.mock_calls) >= 2 for c in _chown.mock_calls: - assert c.args[1:] == (0, 0) + assert c == mock.call(mock.ANY, 0, 0) assert (dst / "foo.txt").exists() @@ -187,7 +187,7 @@ class TestCopyFiles: self._copy_files([file1], dst, uid=0, gid=0) assert len(_chown.mock_calls) >= 1 for c in _chown.mock_calls: - assert c.args[1:] == (0, 0) + assert c == mock.call(mock.ANY, 0, 0) assert (dst / "f1.txt").exists() @@ -270,7 +270,7 @@ class TestMoveFiles: self._move_files([file1], dst, uid=0, gid=0) assert len(_chown.mock_calls) >= 1 for c in _chown.mock_calls: - assert c.args[1:] == (0, 0) + assert c == mock.call(mock.ANY, 0, 0) assert dst.is_file() assert not file1.exists() @@ -288,9 +288,9 @@ def test_recursive_chown(tmp_path): _chown.return_value = None _cephadm.recursive_chown(str(d1), uid=500, gid=500) assert len(_chown.mock_calls) == 3 - assert _chown.mock_calls[0].args == (str(d1), 500, 500) - assert _chown.mock_calls[1].args == (str(d2), 500, 500) - assert _chown.mock_calls[2].args == (str(f1), 500, 500) + assert _chown.mock_calls[0] == mock.call(str(d1), 500, 500) + assert _chown.mock_calls[1] == mock.call(str(d2), 500, 500) + assert _chown.mock_calls[2] == mock.call(str(f1), 500, 500) class TestFindExecutable: -- 2.39.5