Fix service integration tests.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2015-08-24 14:49:51 -04:00
parent 71ff872e8e
commit bd7c032a00
3 changed files with 8 additions and 13 deletions

View File

@ -19,7 +19,7 @@ def parallel_execute(objects, obj_callable, msg_index, msg):
For a given list of objects, call the callable passing in the first
object we give it.
"""
stream = get_output_stream()
stream = get_output_stream(sys.stdout)
lines = []
errors = {}
@ -71,7 +71,7 @@ def parallel_execute(objects, obj_callable, msg_index, msg):
stream.write("ERROR: for {} {} \n".format(error, errors[error]))
def get_output_stream(stream=sys.stdout):
def get_output_stream(stream):
if six.PY3:
return stream
return codecs.getwriter('utf-8')(stream)

View File

@ -3,3 +3,4 @@ git+https://github.com/pyinstaller/pyinstaller.git@12e40471c77f588ea5be352f7219c
mock >= 1.0.1
nose==1.3.4
pep8==1.6.1
coverage==3.7.1

View File

@ -581,8 +581,7 @@ class ServiceTest(DockerClientTestCase):
service.scale(0)
self.assertEqual(len(service.containers()), 0)
@mock.patch('sys.stdout', new_callable=StringIO)
def test_scale_with_stopped_containers(self, mock_stdout):
def test_scale_with_stopped_containers(self):
"""
Given there are some stopped containers and scale is called with a
desired number that is the same as the number of stopped containers,
@ -591,15 +590,11 @@ class ServiceTest(DockerClientTestCase):
service = self.create_service('web')
next_number = service._next_container_number()
valid_numbers = [next_number, next_number + 1]
service.create_container(number=next_number, quiet=True)
service.create_container(number=next_number + 1, quiet=True)
service.create_container(number=next_number)
service.create_container(number=next_number + 1)
for container in service.containers():
self.assertFalse(container.is_running)
service.scale(2)
self.assertEqual(len(service.containers()), 2)
with mock.patch('sys.stdout', new_callable=StringIO) as mock_stdout:
service.scale(2)
for container in service.containers():
self.assertTrue(container.is_running)
self.assertTrue(container.number in valid_numbers)
@ -701,7 +696,6 @@ class ServiceTest(DockerClientTestCase):
results in warning output.
"""
service = self.create_service('web', container_name='custom-container')
self.assertEqual(service.custom_container_name(), 'custom-container')
service.scale(3)