Comment 2 for bug 1272428

Revision history for this message
Max Lobur (max-lobur) wrote :

Found one more - assert_called_once https://github.com/openstack/ironic/blob/7e4e859363bd87846323c17a40ea0718340cef71/ironic/tests/conductor/test_manager.py#L427

(Pdb) deploy
<MagicMock name='tear_down' id='59835280'>

(Pdb) dir(deploy)
['assert_any_call', 'assert_called_once_with', 'assert_called_with', 'assert_has_calls', 'attach_mock', 'call_args', 'call_args_list', 'call_count', 'called', 'configure_mock', 'method_calls', 'mock_add_spec', 'mock_calls', 'reset_mock', 'return_value', 'side_effect']

(Pdb) 'assert_called_once' in dir(deploy)
False

(Pdb) deploy.assert_called_once() # This does nothing
<MagicMock name='tear_down.assert_called_once()' id='59810832'>

# It appears in interface if called at least once - be careful in your tests!
(Pdb) 'assert_called_once' in dir(deploy)
True

(Pdb) deploy.assert_called_once() # Still does nothing
<MagicMock name='tear_down.assert_called_once()' id='59810832'>