'``DockerClient.list`` will only an inspect an image ID once, caching
the resulting data.'

@capture_logging(assertHasMessage, LOG_CACHED_IMAGE)
def test_list_image_data_cached(self, logger):

    name = random_name(self)
    d = self.start_container(name, image_name=ANY_IMAGE)
    def started(client):
        listing = client.list()
        def listed(_):
            class FakeAPIError(Exception, ):
                pass
            def fake_inspect_image(image):
                raise FakeAPIError('Tried    to    inspect    image    {}    twice.'.format(image))
            if isinstance(client, NamespacedDockerClient):
                docker_client = client._client._client
            else:
                docker_client = client._client
            self.patch(docker_client, 'inspect_image', fake_inspect_image)
            cached_listing = client.list()
            cached_listing.addCallback((lambda _: None))
            return cached_listing
        listing.addCallback(listed)
        return listing
    d.addCallback(started)
    return d
