summaryrefslogtreecommitdiff
path: root/tests/integration/errors_test.py
blob: dc5cef4945a608eb7e0a202366b21b6cffdaab29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from docker.errors import APIError
from .base import BaseAPIIntegrationTest, BUSYBOX


class ErrorsTest(BaseAPIIntegrationTest):
    def test_api_error_parses_json(self):
        container = self.client.create_container(BUSYBOX, ['sleep', '10'])
        self.client.start(container['Id'])
        with self.assertRaises(APIError) as cm:
            self.client.remove_container(container['Id'])
        explanation = cm.exception.explanation
        assert 'You cannot remove a running container' in explanation
        assert '{"message":' not in explanation
        self.client.remove_container(container['Id'], force=True)