浏览代码

Fix service integration tests.

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 10 年之前
父节点
当前提交
bd7c032a00
共有 3 个文件被更改,包括 8 次插入13 次删除
  1. 2 2
      compose/utils.py
  2. 1 0
      requirements-dev.txt
  3. 5 11
      tests/integration/service_test.py

+ 2 - 2
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)

+ 1 - 0
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

+ 5 - 11
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)