diff --git a/Dockerfile b/Dockerfile index 1986ac5a5..a4cc99fea 100644 --- a/Dockerfile +++ b/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 diff --git a/compose/container.py b/compose/container.py index f727c8673..6f426532a 100644 --- a/compose/container.py +++ b/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): diff --git a/compose/progress_stream.py b/compose/progress_stream.py index 582c09fb9..e2300fd4a 100644 --- a/compose/progress_stream.py +++ b/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) diff --git a/compose/project.py b/compose/project.py index d14941e72..cd88b2988 100644 --- a/compose/project.py +++ b/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 diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 000000000..cc9842253 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +flake8 +tox diff --git a/script/test-versions b/script/test-versions index d67a6f5e1..e2102e449 100755 --- a/script/test-versions +++ b/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 diff --git a/setup.py b/setup.py index b7fd44034..cdb5686cf 100644 --- a/setup.py +++ b/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') diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py index 609370a3e..9552bf6a6 100644 --- a/tests/integration/cli_test.py +++ b/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] diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index fe54d4ae2..effd356df 100644 --- a/tests/integration/service_test.py +++ b/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( diff --git a/tests/unit/progress_stream_test.py b/tests/unit/progress_stream_test.py index 5674f4e4e..e38a74435 100644 --- a/tests/unit/progress_stream_test.py +++ b/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": ' diff --git a/tox.ini b/tox.ini index 35523a969..2e3edd2a5 100644 --- a/tox.ini +++ b/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