Преглед на файлове

Run tests against Python 2.6, 2.7, 3.3, 3.4 and PyPy2

In particular it includes:
- some extension of CONTRIBUTING.md
- one fix for Python 2.6 in tests/integration/cli_test.py
- one fix for Python 3.3 in tests/integration/service_test.py
- removal of unused imports

Make stream_output Python 3-compatible

Signed-off-by: Frank Sachsenheim <[email protected]>
funkyfuture преди 10 години
родител
ревизия
9aa61e596e
променени са 11 файла, в които са добавени 16 реда и са изтрити 13 реда
  1. 2 2
      Dockerfile
  2. 3 4
      compose/container.py
  3. 2 0
      compose/progress_stream.py
  4. 1 1
      compose/project.py
  5. 2 0
      requirements-dev.txt
  6. 1 1
      script/test-versions
  7. 1 1
      setup.py
  8. 1 1
      tests/integration/cli_test.py
  9. 1 1
      tests/integration/service_test.py
  10. 0 1
      tests/unit/progress_stream_test.py
  11. 2 1
      tox.ini

+ 2 - 2
Dockerfile

@@ -66,8 +66,8 @@ WORKDIR /code/
 ADD requirements.txt /code/
 RUN pip install -r requirements.txt
 
-ADD requirements-dev-py2.txt /code/
-RUN pip install -r requirements-dev-py2.txt
+ADD requirements-dev.txt /code/
+RUN pip install -r requirements-dev.txt
 
 RUN pip install tox==2.1.1
 

+ 3 - 4
compose/container.py

@@ -1,9 +1,8 @@
 from __future__ import absolute_import
 from __future__ import unicode_literals
 
-from functools import reduce
-
-import six
+from six import iteritems
+from six.moves import reduce
 
 from .const import LABEL_CONTAINER_NUMBER
 from .const import LABEL_SERVICE
@@ -90,7 +89,7 @@ class Container(object):
                 private=private, **public[0])
 
         return ', '.join(format_port(*item)
-                         for item in sorted(six.iteritems(self.ports)))
+                         for item in sorted(iteritems(self.ports)))
 
     @property
     def labels(self):

+ 2 - 0
compose/progress_stream.py

@@ -17,6 +17,8 @@ def stream_output(output, stream):
     diff = 0
 
     for chunk in output:
+        if six.PY3 and not isinstance(chunk, str):
+            chunk = chunk.decode('utf-8')
         event = json.loads(chunk)
         all_events.append(event)
 

+ 1 - 1
compose/project.py

@@ -2,9 +2,9 @@ from __future__ import absolute_import
 from __future__ import unicode_literals
 
 import logging
-from functools import reduce
 
 from docker.errors import APIError
+from six.moves import reduce
 
 from .config import ConfigurationError
 from .config import get_service_name_from_net

+ 2 - 0
requirements-dev.txt

@@ -0,0 +1,2 @@
+flake8
+tox

+ 1 - 1
script/test-versions

@@ -24,5 +24,5 @@ for version in $DOCKER_VERSIONS; do
     -e "DOCKER_DAEMON_ARGS" \
     --entrypoint="script/dind" \
     "$TAG" \
-    script/wrapdocker nosetests --with-coverage --cover-branches --cover-package=compose --cover-erase --cover-html-dir=coverage-html --cover-html "$@"
+    script/wrapdocker tox "$@"
 done

+ 1 - 1
setup.py

@@ -48,7 +48,7 @@ tests_require = [
 ]
 
 
-if sys.version_info < (2, 6):
+if sys.version_info < (2, 7):
     tests_require.append('unittest2')
 if sys.version_info[:1] < (3,):
     tests_require.append('pyinstaller')

+ 1 - 1
tests/integration/cli_test.py

@@ -275,7 +275,7 @@ class CLITestCase(DockerClientTestCase):
         self.command.base_dir = 'tests/fixtures/user-composefile'
         name = 'service'
         user = 'sshd'
-        args = ['run', '--user={}'.format(user), name]
+        args = ['run', '--user={user}'.format(user=user), name]
         self.command.dispatch(args, None)
         service = self.project.get_service(name)
         container = service.containers(stopped=True, one_off=True)[0]

+ 1 - 1
tests/integration/service_test.py

@@ -358,7 +358,7 @@ class ServiceTest(DockerClientTestCase):
         )
 
         old_container = create_and_start_container(service)
-        self.assertEqual(old_container.get('Volumes').keys(), ['/data'])
+        self.assertEqual(list(old_container.get('Volumes').keys()), ['/data'])
         volume_path = old_container.get('Volumes')['/data']
 
         new_container, = service.execute_convergence_plan(

+ 0 - 1
tests/unit/progress_stream_test.py

@@ -8,7 +8,6 @@ from tests import unittest
 
 
 class ProgressStreamTestCase(unittest.TestCase):
-
     def test_stream_output(self):
         output = [
             '{"status": "Downloading", "progressDetail": {"current": '

+ 2 - 1
tox.ini

@@ -8,7 +8,7 @@ passenv =
 deps =
     -rrequirements.txt
 commands =
-    nosetests -v {posargs}
+    nosetests -v --with-coverage --cover-branches --cover-package=compose --cover-erase --cover-html-dir=coverage-html --cover-html {posargs}
     flake8 compose tests setup.py
 
 [testenv:pre-commit]
@@ -38,6 +38,7 @@ deps =
 [testenv:py34]
 deps = {[testenv:py33]deps}
 
+# TODO pypy3
 
 [flake8]
 # ignore line-length for now