Skip to content

Commit 5064995

Browse files
committed
tests/integration: update some tests for updated error-messages
I was in the process of cleaning up some error-messages, and it looks like the docker-py tests were depending on strings that will be removed; =================================== FAILURES =================================== _____________ CreateContainerTest.test_create_with_restart_policy ______________ tests/integration/api_container_test.py:126: in test_create_with_restart_policy assert 'You cannot remove ' in err E AssertionError: assert 'You cannot remove ' in 'cannot remove container d11580f6078108691096ec8a23404a6bda9ad1d1b2bafe88b17d127a67728833: container is restarting: stop the container before removing or force remove' ____________________ ErrorsTest.test_api_error_parses_json _____________________ tests/integration/errors_test.py:13: in test_api_error_parses_json assert 'You cannot remove a running container' in explanation E AssertionError: assert 'You cannot remove a running container' in 'cannot remove container 4b90ce2e907dd0f99d0f561619b803e7a2a31809ced366c537874dd13f8a47ec: container is running: stop the container before removing or force remove' This updates the tests to match on a string that will be present in both the old and new error-messages, but added a "lower()", so that matching will be done case-insensitive (Go errors generally should be lowercase). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 54ec0c6 commit 5064995

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/integration/api_container_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def test_create_with_restart_policy(self):
122122
self.client.wait(id)
123123
with pytest.raises(docker.errors.APIError) as exc:
124124
self.client.remove_container(id)
125-
err = exc.value.explanation
126-
assert 'You cannot remove ' in err
125+
err = exc.value.explanation.lower()
126+
assert 'stop the container before' in err
127127
self.client.remove_container(id, force=True)
128128

129129
def test_create_container_with_volumes_from(self):

tests/integration/errors_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_api_error_parses_json(self):
99
self.client.start(container['Id'])
1010
with pytest.raises(APIError) as cm:
1111
self.client.remove_container(container['Id'])
12-
explanation = cm.value.explanation
13-
assert 'You cannot remove a running container' in explanation
12+
explanation = cm.value.explanation.lower()
13+
assert 'stop the container before' in explanation
1414
assert '{"message":' not in explanation
1515
self.client.remove_container(container['Id'], force=True)

0 commit comments

Comments
 (0)