1
0
Fork 0

Test: Fix test_subcmds_sync.py for Python <= 3.7

This change fixes the failing test_interleaved_shared_objdir_serial
in Python 3.7 and earlier.

In the test the execute_mock.call_args could return either a tuple
of arguments or a mock._Call object, depending on the Python version.
In Python 3.7 and below, a mock._Call object was returned, causing
the test to fail when directly accessing call_args.args.

By checking isinstance(call_args, mock._Call), this commit ensures
compatibility across Python versions.

Change-Id: I6790dffc40cebb7dda47b0f477a1e1586b9da239
This commit is contained in:
Daniel Kutik 2025-06-22 10:10:42 +02:00
parent 6b8e9fc8db
commit 3598279c5f

View file

@ -659,7 +659,10 @@ class InterleavedSyncTest(unittest.TestCase):
) )
execute_mock.assert_called_once() execute_mock.assert_called_once()
jobs_arg, _, work_items = execute_mock.call_args.args call_args = execute_mock.call_args
if isinstance(call_args, mock._Call):
call_args = call_args[0]
jobs_arg, _, work_items = call_args
self.assertEqual(jobs_arg, 2) self.assertEqual(jobs_arg, 2)
work_items_sets = {frozenset(item) for item in work_items} work_items_sets = {frozenset(item) for item in work_items}
expected_sets = {frozenset([0, 2]), frozenset([1])} expected_sets = {frozenset([0, 2]), frozenset([1])}