from unittest import TestCase from unittest.mock import Mock, call class TestMock(TestCase): def test_assert_has_calls(self): callable_mock = Mock() # in my case this part uses multithreading and then no strict order what runs first # i have only rule that 1 should called before 3 and 2 should called before 4 and want to test that callable_mock(1) callable_mock(2) callable_mock(3) callable_mock(4) callable_mock.assert_has_calls([call(1), call(3)], any_order=False) callable_mock.assert_has_calls([call(2), call(4)], any_order=False)