| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | from __future__ import unicode_literalsfrom __future__ import absolute_importfrom compose.service import Servicefrom compose.config import ServiceLoaderfrom compose.const import LABEL_PROJECTfrom compose.cli.docker_client import docker_clientfrom compose.progress_stream import stream_outputfrom .. import unittestclass DockerClientTestCase(unittest.TestCase):    @classmethod    def setUpClass(cls):        cls.client = docker_client()    def tearDown(self):        for c in self.client.containers(                all=True,                filters={'label': '%s=composetest' % LABEL_PROJECT}):            self.client.kill(c['Id'])            self.client.remove_container(c['Id'])        for i in self.client.images(                filters={'label': 'com.docker.compose.test_image'}):            self.client.remove_image(i)    def create_service(self, name, **kwargs):        if 'image' not in kwargs and 'build' not in kwargs:            kwargs['image'] = 'busybox:latest'        if 'command' not in kwargs:            kwargs['command'] = ["top"]        options = ServiceLoader(working_dir='.').make_service_dict(name, kwargs)        return Service(            project='composetest',            client=self.client,            **options        )    def check_build(self, *args, **kwargs):        kwargs.setdefault('rm', True)        build_output = self.client.build(*args, **kwargs)        stream_output(build_output, open('/dev/null', 'w'))
 |