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 <funkyfuture@riseup.net>
This commit is contained in:
funkyfuture 2015-03-26 23:28:02 +01:00 committed by Daniel Nephin
parent 809443d6d0
commit 9aa61e596e
11 changed files with 16 additions and 13 deletions

View File

@ -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

View File

@ -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):

View File

@ -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)

View File

@ -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
requirements-dev.txt Normal file
View File

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

View File

@ -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

View File

@ -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')

View File

@ -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]

View File

@ -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(

View File

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

View File

@ -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