From fe6103f5011369b303868b36376a49ee709f3fa2 Mon Sep 17 00:00:00 2001 From: Kuba Mazurek Date: Mon, 27 Sep 2021 18:38:48 +0200 Subject: [PATCH] Allow calling stop on an already stopped Docker container --- goth/runner/container/__init__.py | 7 ++++++- test/unit/runner/container/test_container.py | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/goth/runner/container/__init__.py b/goth/runner/container/__init__.py index ef0acf020..412e75dd6 100644 --- a/goth/runner/container/__init__.py +++ b/goth/runner/container/__init__.py @@ -154,7 +154,12 @@ def __init__( }, { "trigger": "stop", - "source": [State.running, State.paused, State.restarting], + "source": [ + State.exited, + State.running, + State.paused, + State.restarting, + ], "dest": State.exited, "before": self._container.stop, }, diff --git a/test/unit/runner/container/test_container.py b/test/unit/runner/container/test_container.py index f5fab4a07..443131900 100644 --- a/test/unit/runner/container/test_container.py +++ b/test/unit/runner/container/test_container.py @@ -86,8 +86,6 @@ def test_container_stop(docker_container, mock_container): mock_container.status = "exited" mock_container.stop.assert_called_once() - with pytest.raises(transitions.MachineError, match=r"Can't trigger event stop.*"): - docker_container.stop() def test_container_remove(docker_container, mock_container):