'``DockerClient.list()`` can list containers whose image is missing.
The resulting output may be inaccurate, but that\'s OK: this only
happens for non-running containers, who at worst we\'re going to
restart anyway.'

def test_list_with_missing_image(self):

    path = FilePath(self.mktemp())
    path.makedirs()
    path.child('Dockerfile.in').setContent('FROM    busybox\nCMD    /bin/true\n')
    builder = DockerImageBuilder(test=self, source_dir=path, cleanup=False)
    d = builder.build()
    def image_built(image_name):
        name = random_name(self)
        d = self.start_container(unit_name=name, image_name=image_name, expected_states=(u'inactive',))
        return d.addCallback((lambda ignored: (name, image_name)))
    d.addCallback(image_built)
    def stopped_container_exists((name, image_name)):
        docker_client = dockerpy_client()
        docker_client.remove_image(image_name, force=True)
        client = self.make_client()
        listed = client.list()
        listed.addCallback((lambda results: self.assertIn((name, 'inactive'), [(unit.name, unit.activation_state) for unit in results])))
        return listed
    d.addCallback(stopped_container_exists)
    return d
