2014-01-06 03:26:32 +01:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import absolute_import
|
2013-12-20 21:28:24 +01:00
|
|
|
from fig import Service
|
2014-04-25 23:58:21 +02:00
|
|
|
from fig.service import CannotBeScaledError
|
2014-05-29 09:40:11 +02:00
|
|
|
from fig.container import Container
|
2014-04-23 19:20:27 +02:00
|
|
|
from fig.packages.docker.errors import APIError
|
2013-12-10 21:47:08 +01:00
|
|
|
from .testcases import DockerClientTestCase
|
2014-07-11 19:18:05 +02:00
|
|
|
import os
|
2013-12-09 16:00:01 +01:00
|
|
|
|
2013-12-18 18:01:50 +01:00
|
|
|
class ServiceTest(DockerClientTestCase):
|
2013-12-09 16:00:41 +01:00
|
|
|
def test_containers(self):
|
|
|
|
foo = self.create_service('foo')
|
|
|
|
bar = self.create_service('bar')
|
|
|
|
|
2013-12-20 17:22:54 +01:00
|
|
|
foo.start_container()
|
2013-12-09 16:00:41 +01:00
|
|
|
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(len(foo.containers()), 1)
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertEqual(foo.containers()[0].name, 'figtest_foo_1')
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(len(bar.containers()), 0)
|
2013-12-09 16:00:41 +01:00
|
|
|
|
2013-12-20 17:22:54 +01:00
|
|
|
bar.start_container()
|
|
|
|
bar.start_container()
|
2013-12-09 16:00:41 +01:00
|
|
|
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(len(foo.containers()), 1)
|
|
|
|
self.assertEqual(len(bar.containers()), 2)
|
2013-12-09 16:00:41 +01:00
|
|
|
|
2013-12-18 19:37:48 +01:00
|
|
|
names = [c.name for c in bar.containers()]
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertIn('figtest_bar_1', names)
|
|
|
|
self.assertIn('figtest_bar_2', names)
|
2013-12-19 16:16:17 +01:00
|
|
|
|
2013-12-20 11:46:55 +01:00
|
|
|
def test_containers_one_off(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
container = db.create_container(one_off=True)
|
|
|
|
self.assertEqual(db.containers(stopped=True), [])
|
|
|
|
self.assertEqual(db.containers(one_off=True, stopped=True), [container])
|
|
|
|
|
2013-12-19 16:16:17 +01:00
|
|
|
def test_project_is_added_to_container_name(self):
|
2014-01-02 16:27:51 +01:00
|
|
|
service = self.create_service('web')
|
2013-12-20 17:22:54 +01:00
|
|
|
service.start_container()
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertEqual(service.containers()[0].name, 'figtest_web_1')
|
2013-12-09 19:42:33 +01:00
|
|
|
|
2013-12-20 17:22:54 +01:00
|
|
|
def test_start_stop(self):
|
2013-12-19 15:47:43 +01:00
|
|
|
service = self.create_service('scalingtest')
|
2013-12-20 17:22:54 +01:00
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 0)
|
2013-12-09 12:41:05 +01:00
|
|
|
|
2013-12-20 17:22:54 +01:00
|
|
|
service.create_container()
|
|
|
|
self.assertEqual(len(service.containers()), 0)
|
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
2013-12-09 12:41:05 +01:00
|
|
|
|
2013-12-10 21:47:08 +01:00
|
|
|
service.start()
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(len(service.containers()), 1)
|
2013-12-20 17:22:54 +01:00
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
2013-12-09 12:41:05 +01:00
|
|
|
|
2013-12-20 17:22:54 +01:00
|
|
|
service.stop(timeout=1)
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(len(service.containers()), 0)
|
2013-12-20 17:22:54 +01:00
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
2013-12-09 22:39:11 +01:00
|
|
|
|
2013-12-20 17:22:54 +01:00
|
|
|
service.stop(timeout=1)
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(len(service.containers()), 0)
|
2013-12-20 17:22:54 +01:00
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
2013-12-09 22:39:11 +01:00
|
|
|
|
2013-12-20 17:53:07 +01:00
|
|
|
def test_kill_remove(self):
|
|
|
|
service = self.create_service('scalingtest')
|
|
|
|
|
|
|
|
service.start_container()
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
|
|
|
|
service.remove_stopped()
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
|
|
|
|
service.kill()
|
|
|
|
self.assertEqual(len(service.containers()), 0)
|
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
|
|
|
|
|
|
|
service.remove_stopped()
|
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 0)
|
|
|
|
|
2013-12-20 11:46:55 +01:00
|
|
|
def test_create_container_with_one_off(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
container = db.create_container(one_off=True)
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertEqual(container.name, 'figtest_db_run_1')
|
2013-12-20 11:46:55 +01:00
|
|
|
|
2013-12-20 13:55:45 +01:00
|
|
|
def test_create_container_with_one_off_when_existing_container_is_running(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
db.start()
|
|
|
|
container = db.create_container(one_off=True)
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertEqual(container.name, 'figtest_db_run_1')
|
2013-12-20 13:55:45 +01:00
|
|
|
|
2014-01-15 13:43:40 +01:00
|
|
|
def test_create_container_with_unspecified_volume(self):
|
|
|
|
service = self.create_service('db', volumes=['/var/db'])
|
|
|
|
container = service.create_container()
|
|
|
|
service.start_container(container)
|
|
|
|
self.assertIn('/var/db', container.inspect()['Volumes'])
|
|
|
|
|
2014-04-25 13:28:00 +02:00
|
|
|
def test_create_container_with_specified_volume(self):
|
|
|
|
service = self.create_service('db', volumes=['/tmp:/host-tmp'])
|
|
|
|
container = service.create_container()
|
|
|
|
service.start_container(container)
|
|
|
|
self.assertIn('/host-tmp', container.inspect()['Volumes'])
|
|
|
|
|
2014-05-29 09:40:11 +02:00
|
|
|
def test_create_container_with_volumes_from(self):
|
|
|
|
volume_service = self.create_service('data')
|
|
|
|
volume_container_1 = volume_service.create_container()
|
|
|
|
volume_container_2 = Container.create(self.client, image='busybox:latest', command=["/bin/sleep", "300"])
|
|
|
|
host_service = self.create_service('host', volumes_from=[volume_service, volume_container_2])
|
|
|
|
host_container = host_service.create_container()
|
|
|
|
host_service.start_container(host_container)
|
|
|
|
self.assertIn(volume_container_1.id, host_container.inspect()['HostConfig']['VolumesFrom'])
|
|
|
|
self.assertIn(volume_container_2.id, host_container.inspect()['HostConfig']['VolumesFrom'])
|
|
|
|
|
2014-01-03 12:18:59 +01:00
|
|
|
def test_recreate_containers(self):
|
2014-02-21 19:12:51 +01:00
|
|
|
service = self.create_service(
|
|
|
|
'db',
|
|
|
|
environment={'FOO': '1'},
|
|
|
|
volumes=['/var/db'],
|
2014-07-11 23:52:47 +02:00
|
|
|
entrypoint=['sleep'],
|
|
|
|
command=['300']
|
2014-02-21 19:12:51 +01:00
|
|
|
)
|
2014-01-15 14:06:25 +01:00
|
|
|
old_container = service.create_container()
|
2014-07-11 23:52:47 +02:00
|
|
|
self.assertEqual(old_container.dictionary['Config']['Entrypoint'], ['sleep'])
|
|
|
|
self.assertEqual(old_container.dictionary['Config']['Cmd'], ['300'])
|
2014-01-29 14:57:28 +01:00
|
|
|
self.assertIn('FOO=1', old_container.dictionary['Config']['Env'])
|
2014-01-15 18:06:16 +01:00
|
|
|
self.assertEqual(old_container.name, 'figtest_db_1')
|
2014-01-15 14:06:25 +01:00
|
|
|
service.start_container(old_container)
|
|
|
|
volume_path = old_container.inspect()['Volumes']['/var/db']
|
2014-01-15 13:22:55 +01:00
|
|
|
|
2014-01-15 18:06:16 +01:00
|
|
|
num_containers_before = len(self.client.containers(all=True))
|
|
|
|
|
2014-01-15 13:22:55 +01:00
|
|
|
service.options['environment']['FOO'] = '2'
|
2014-04-23 16:46:26 +02:00
|
|
|
tuples = service.recreate_containers()
|
|
|
|
self.assertEqual(len(tuples), 1)
|
2014-01-15 14:06:25 +01:00
|
|
|
|
2014-04-23 16:46:26 +02:00
|
|
|
intermediate_container = tuples[0][0]
|
|
|
|
new_container = tuples[0][1]
|
2014-02-21 19:12:51 +01:00
|
|
|
self.assertEqual(intermediate_container.dictionary['Config']['Entrypoint'], ['echo'])
|
2014-01-18 15:11:25 +01:00
|
|
|
|
2014-07-11 23:52:47 +02:00
|
|
|
self.assertEqual(new_container.dictionary['Config']['Entrypoint'], ['sleep'])
|
|
|
|
self.assertEqual(new_container.dictionary['Config']['Cmd'], ['300'])
|
2014-01-29 14:57:28 +01:00
|
|
|
self.assertIn('FOO=2', new_container.dictionary['Config']['Env'])
|
2014-01-15 18:06:16 +01:00
|
|
|
self.assertEqual(new_container.name, 'figtest_db_1')
|
2014-01-15 14:06:25 +01:00
|
|
|
self.assertEqual(new_container.inspect()['Volumes']['/var/db'], volume_path)
|
2014-05-29 09:40:11 +02:00
|
|
|
self.assertIn(intermediate_container.id, new_container.dictionary['HostConfig']['VolumesFrom'])
|
2014-01-15 13:22:55 +01:00
|
|
|
|
2014-04-23 16:46:26 +02:00
|
|
|
self.assertEqual(len(self.client.containers(all=True)), num_containers_before)
|
2014-01-15 14:06:25 +01:00
|
|
|
self.assertNotEqual(old_container.id, new_container.id)
|
2014-04-23 16:46:26 +02:00
|
|
|
self.assertRaises(APIError, lambda: self.client.inspect_container(intermediate_container.id))
|
2014-01-03 12:18:59 +01:00
|
|
|
|
2014-07-11 23:52:47 +02:00
|
|
|
def test_recreate_containers_when_containers_are_stopped(self):
|
|
|
|
service = self.create_service(
|
|
|
|
'db',
|
|
|
|
environment={'FOO': '1'},
|
|
|
|
volumes=['/var/db'],
|
|
|
|
entrypoint=['sleep'],
|
|
|
|
command=['300']
|
|
|
|
)
|
|
|
|
old_container = service.create_container()
|
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
|
|
|
service.recreate_containers()
|
|
|
|
self.assertEqual(len(service.containers(stopped=True)), 1)
|
|
|
|
|
2013-12-10 21:51:55 +01:00
|
|
|
def test_start_container_passes_through_options(self):
|
2013-12-10 22:01:39 +01:00
|
|
|
db = self.create_service('db')
|
|
|
|
db.start_container(environment={'FOO': 'BAR'})
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(db.containers()[0].environment['FOO'], 'BAR')
|
2013-12-10 22:01:39 +01:00
|
|
|
|
|
|
|
def test_start_container_inherits_options_from_constructor(self):
|
2013-12-10 21:51:55 +01:00
|
|
|
db = self.create_service('db', environment={'FOO': 'BAR'})
|
|
|
|
db.start_container()
|
2013-12-18 19:37:48 +01:00
|
|
|
self.assertEqual(db.containers()[0].environment['FOO'], 'BAR')
|
2013-12-10 21:51:55 +01:00
|
|
|
|
|
|
|
def test_start_container_creates_links(self):
|
2013-12-09 22:39:11 +01:00
|
|
|
db = self.create_service('db')
|
2014-03-01 17:30:33 +01:00
|
|
|
web = self.create_service('web', links=[(db, None)])
|
2013-12-10 21:51:55 +01:00
|
|
|
db.start_container()
|
|
|
|
web.start_container()
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertIn('figtest_db_1', web.containers()[0].links())
|
2014-01-27 16:29:58 +01:00
|
|
|
self.assertIn('db_1', web.containers()[0].links())
|
2014-01-19 21:43:31 +01:00
|
|
|
|
2014-03-03 01:54:47 +01:00
|
|
|
def test_start_container_creates_links_with_names(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
web = self.create_service('web', links=[(db, 'custom_link_name')])
|
|
|
|
db.start_container()
|
|
|
|
web.start_container()
|
|
|
|
self.assertIn('custom_link_name', web.containers()[0].links())
|
|
|
|
|
2014-03-06 19:59:24 +01:00
|
|
|
def test_start_normal_container_does_not_create_links_to_its_own_service(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
c1 = db.start_container()
|
|
|
|
c2 = db.start_container()
|
|
|
|
self.assertNotIn(c1.name, c2.links())
|
|
|
|
|
|
|
|
def test_start_one_off_container_creates_links_to_its_own_service(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
c1 = db.start_container()
|
|
|
|
c2 = db.start_container(one_off=True)
|
|
|
|
self.assertIn(c1.name, c2.links())
|
2013-12-09 22:39:11 +01:00
|
|
|
|
2013-12-13 21:36:10 +01:00
|
|
|
def test_start_container_builds_images(self):
|
|
|
|
service = Service(
|
|
|
|
name='test',
|
|
|
|
client=self.client,
|
2013-12-14 17:34:24 +01:00
|
|
|
build='tests/fixtures/simple-dockerfile',
|
2014-01-02 16:27:51 +01:00
|
|
|
project='figtest',
|
2013-12-13 21:36:10 +01:00
|
|
|
)
|
2013-12-20 17:22:54 +01:00
|
|
|
container = service.start_container()
|
2013-12-18 19:37:48 +01:00
|
|
|
container.wait()
|
|
|
|
self.assertIn('success', container.logs())
|
2014-01-02 16:27:51 +01:00
|
|
|
self.assertEqual(len(self.client.images(name='figtest_test')), 1)
|
2013-12-20 17:23:40 +01:00
|
|
|
|
|
|
|
def test_start_container_uses_tagged_image_if_it_exists(self):
|
2014-01-02 16:27:51 +01:00
|
|
|
self.client.build('tests/fixtures/simple-dockerfile', tag='figtest_test')
|
2013-12-20 17:23:40 +01:00
|
|
|
service = Service(
|
|
|
|
name='test',
|
|
|
|
client=self.client,
|
|
|
|
build='this/does/not/exist/and/will/throw/error',
|
2014-01-02 16:27:51 +01:00
|
|
|
project='figtest',
|
2013-12-20 17:23:40 +01:00
|
|
|
)
|
2013-12-20 20:30:31 +01:00
|
|
|
container = service.start_container()
|
2013-12-20 17:23:40 +01:00
|
|
|
container.wait()
|
|
|
|
self.assertIn('success', container.logs())
|
2013-12-18 12:14:14 +01:00
|
|
|
|
|
|
|
def test_start_container_creates_ports(self):
|
|
|
|
service = self.create_service('web', ports=[8000])
|
2013-12-18 19:37:48 +01:00
|
|
|
container = service.start_container().inspect()
|
2014-03-04 18:58:42 +01:00
|
|
|
self.assertEqual(list(container['NetworkSettings']['Ports'].keys()), ['8000/tcp'])
|
|
|
|
self.assertNotEqual(container['NetworkSettings']['Ports']['8000/tcp'][0]['HostPort'], '8000')
|
2013-12-18 12:14:14 +01:00
|
|
|
|
2014-03-04 00:51:24 +01:00
|
|
|
def test_start_container_stays_unpriviliged(self):
|
|
|
|
service = self.create_service('web')
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['HostConfig']['Privileged'], False)
|
|
|
|
|
|
|
|
def test_start_container_becomes_priviliged(self):
|
|
|
|
service = self.create_service('web', privileged = True)
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['HostConfig']['Privileged'], True)
|
|
|
|
|
2014-03-04 18:59:42 +01:00
|
|
|
def test_expose_does_not_publish_ports(self):
|
|
|
|
service = self.create_service('web', expose=[8000])
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['NetworkSettings']['Ports'], {'8000/tcp': None})
|
|
|
|
|
2014-01-22 18:01:10 +01:00
|
|
|
def test_start_container_creates_port_with_explicit_protocol(self):
|
|
|
|
service = self.create_service('web', ports=['8000/udp'])
|
|
|
|
container = service.start_container().inspect()
|
2014-03-04 18:58:42 +01:00
|
|
|
self.assertEqual(list(container['NetworkSettings']['Ports'].keys()), ['8000/udp'])
|
2014-01-22 18:01:10 +01:00
|
|
|
|
2013-12-18 12:14:14 +01:00
|
|
|
def test_start_container_creates_fixed_external_ports(self):
|
|
|
|
service = self.create_service('web', ports=['8000:8000'])
|
2013-12-18 19:37:48 +01:00
|
|
|
container = service.start_container().inspect()
|
2014-03-04 18:58:42 +01:00
|
|
|
self.assertIn('8000/tcp', container['NetworkSettings']['Ports'])
|
|
|
|
self.assertEqual(container['NetworkSettings']['Ports']['8000/tcp'][0]['HostPort'], '8000')
|
2013-12-18 12:14:14 +01:00
|
|
|
|
2014-01-16 02:54:05 +01:00
|
|
|
def test_start_container_creates_fixed_external_ports_when_it_is_different_to_internal_port(self):
|
|
|
|
service = self.create_service('web', ports=['8001:8000'])
|
|
|
|
container = service.start_container().inspect()
|
2014-03-04 18:58:42 +01:00
|
|
|
self.assertIn('8000/tcp', container['NetworkSettings']['Ports'])
|
|
|
|
self.assertEqual(container['NetworkSettings']['Ports']['8000/tcp'][0]['HostPort'], '8001')
|
2013-12-09 22:39:11 +01:00
|
|
|
|
2014-06-25 12:49:54 +02:00
|
|
|
def test_port_with_explicit_interface(self):
|
|
|
|
service = self.create_service('web', ports=[
|
|
|
|
'127.0.0.1:8001:8000',
|
|
|
|
'0.0.0.0:9001:9000',
|
|
|
|
])
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['NetworkSettings']['Ports'], {
|
|
|
|
'8000/tcp': [
|
|
|
|
{
|
|
|
|
'HostIp': '127.0.0.1',
|
|
|
|
'HostPort': '8001',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'9000/tcp': [
|
|
|
|
{
|
|
|
|
'HostIp': '0.0.0.0',
|
|
|
|
'HostPort': '9001',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
2014-01-16 18:58:53 +01:00
|
|
|
def test_scale(self):
|
|
|
|
service = self.create_service('web')
|
|
|
|
service.scale(1)
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
service.scale(3)
|
|
|
|
self.assertEqual(len(service.containers()), 3)
|
|
|
|
service.scale(1)
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
service.scale(0)
|
|
|
|
self.assertEqual(len(service.containers()), 0)
|
|
|
|
|
|
|
|
def test_scale_on_service_that_cannot_be_scaled(self):
|
|
|
|
service = self.create_service('web', ports=['8000:8000'])
|
|
|
|
self.assertRaises(CannotBeScaledError, lambda: service.scale(1))
|
|
|
|
|
2014-02-17 22:33:05 +01:00
|
|
|
def test_scale_sets_ports(self):
|
|
|
|
service = self.create_service('web', ports=['8000'])
|
|
|
|
service.scale(2)
|
|
|
|
containers = service.containers()
|
|
|
|
self.assertEqual(len(containers), 2)
|
|
|
|
for container in containers:
|
|
|
|
self.assertEqual(list(container.inspect()['HostConfig']['PortBindings'].keys()), ['8000/tcp'])
|
2014-06-19 12:57:55 +02:00
|
|
|
|
|
|
|
def test_network_mode_none(self):
|
|
|
|
service = self.create_service('web', net='none')
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['HostConfig']['NetworkMode'], 'none')
|
|
|
|
|
|
|
|
def test_network_mode_bridged(self):
|
|
|
|
service = self.create_service('web', net='bridge')
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['HostConfig']['NetworkMode'], 'bridge')
|
|
|
|
|
|
|
|
def test_network_mode_host(self):
|
|
|
|
service = self.create_service('web', net='host')
|
|
|
|
container = service.start_container().inspect()
|
|
|
|
self.assertEqual(container['HostConfig']['NetworkMode'], 'host')
|
2014-07-06 18:09:30 +02:00
|
|
|
|
|
|
|
def test_working_dir_param(self):
|
|
|
|
service = self.create_service('container', working_dir='/working/dir/sample')
|
|
|
|
container = service.create_container().inspect()
|
|
|
|
self.assertEqual(container['Config']['WorkingDir'], '/working/dir/sample')
|
2014-07-11 19:18:05 +02:00
|
|
|
|
|
|
|
def test_split_env(self):
|
|
|
|
service = self.create_service('web', environment=['NORMAL=F1', 'CONTAINS_EQUALS=F=2', 'TRAILING_EQUALS='])
|
|
|
|
env = service.start_container().environment
|
|
|
|
for k,v in {'NORMAL': 'F1', 'CONTAINS_EQUALS': 'F=2', 'TRAILING_EQUALS': ''}.iteritems():
|
|
|
|
self.assertEqual(env[k], v)
|
|
|
|
|
|
|
|
def test_resolve_env(self):
|
|
|
|
service = self.create_service('web', environment={'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': None, 'NO_DEF': None})
|
|
|
|
os.environ['FILE_DEF'] = 'E1'
|
|
|
|
os.environ['FILE_DEF_EMPTY'] = 'E2'
|
|
|
|
os.environ['ENV_DEF'] = 'E3'
|
|
|
|
try:
|
|
|
|
env = service.start_container().environment
|
|
|
|
for k,v in {'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''}.iteritems():
|
|
|
|
self.assertEqual(env[k], v)
|
|
|
|
finally:
|
|
|
|
del os.environ['FILE_DEF']
|
|
|
|
del os.environ['FILE_DEF_EMPTY']
|
|
|
|
del os.environ['ENV_DEF']
|