diff --git a/compose/utils.py b/compose/utils.py index c72922840..30284f97b 100644 --- a/compose/utils.py +++ b/compose/utils.py @@ -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) diff --git a/requirements-dev.txt b/requirements-dev.txt index 9e830733c..c8a694ab2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index f300c6d53..bc9dcc692 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -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)