Cleanup workaround in testcase.py

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2015-11-06 14:30:27 -05:00
parent 0017f43d7f
commit 3474bb6cf5
1 changed files with 12 additions and 23 deletions

View File

@ -42,34 +42,23 @@ class DockerClientTestCase(unittest.TestCase):
if 'command' not in kwargs: if 'command' not in kwargs:
kwargs['command'] = ["top"] kwargs['command'] = ["top"]
links = kwargs.get('links', None) workaround_options = {}
volumes_from = kwargs.get('volumes_from', None) for option in ['links', 'volumes_from', 'net']:
net = kwargs.get('net', None) if option in kwargs:
workaround_options[option] = kwargs.pop(option, None)
workaround_options = ['links', 'volumes_from', 'net'] options = ServiceLoader(
for key in workaround_options: working_dir='.',
try: filename=None,
del kwargs[key] service_name=name,
except KeyError: service_dict=kwargs
pass ).make_service_dict()
options.update(workaround_options)
options = ServiceLoader(working_dir='.', filename=None, service_name=name, service_dict=kwargs).make_service_dict()
labels = options.setdefault('labels', {}) labels = options.setdefault('labels', {})
labels['com.docker.compose.test-name'] = self.id() labels['com.docker.compose.test-name'] = self.id()
if links: return Service(project='composetest', client=self.client, **options)
options['links'] = links
if volumes_from:
options['volumes_from'] = volumes_from
if net:
options['net'] = net
return Service(
project='composetest',
client=self.client,
**options
)
def check_build(self, *args, **kwargs): def check_build(self, *args, **kwargs):
kwargs.setdefault('rm', True) kwargs.setdefault('rm', True)