def tearDown(self):
'''Test case common fixture teardown.'''
logger.info("======= tearDown: %s", self.delete_artifacts)
self.log_docker_constructs()
new_containers = self.new_constructs('container')
new_images = self.new_constructs('image')
new_volumes = self.new_constructs('volume')
if self.delete_artifacts:
# Every case should clean up its docker images and containers.
for container in new_containers:
# These should have been launched with the --rm flag,
# so they should be removed once stopped.
logger.info("REMOVING %s", container['id'])
pexpect.run('docker stop {}'.format(container['id']))
for image in new_images:
logger.info("REMOVING %s", image['id'])
pexpect.run('docker rmi {}'.format(image['id']))
for volume in new_volumes:
logger.info("REMOVING %s", volume['name'])
pexpect.run('docker volume rm {}'.format(volume['name']))
else:
# We'll leave behind any new docker constructs, so we need
# to update the "original docker volumes".
self.constructs['current']['container'].extend(new_containers)
self.constructs['current']['image'].extend(new_images)
self.constructs['current']['volume'].extend(new_volumes)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
评论列表
文章目录