def test_on_kill(): client_mock = mock.Mock(spec=APIClient) operator = DockerOperator(image='ubuntu', owner='unittest', task_id='unittest') operator.cli = client_mock operator.container = {'Id': 'some_id'} operator.on_kill() client_mock.stop.assert_called_with('some_id')