Skip to content

Commit 88811a2

Browse files
committed
Merge pull request #1071 from graingert/support-py35
support Python 3.5
2 parents 26f2b69 + 9809354 commit 88811a2

File tree

10 files changed

+36
-69
lines changed

10 files changed

+36
-69
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
sudo: false
22
language: python
33
python:
4-
- "2.7"
4+
- "3.5"
55
env:
66
- TOX_ENV=py26
77
- TOX_ENV=py27
88
- TOX_ENV=py33
99
- TOX_ENV=py34
10+
- TOX_ENV=py35
1011
- TOX_ENV=flake8
1112
install:
1213
- pip install tox

Dockerfile-py3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.4
1+
FROM python:3.5
22
MAINTAINER Joffrey F <[email protected]>
33

44
RUN mkdir /home/docker-py

docker/api/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def kill(self, container, signal=None):
187187
url = self._url("/containers/{0}/kill", container)
188188
params = {}
189189
if signal is not None:
190-
params['signal'] = signal
190+
params['signal'] = int(signal)
191191
res = self._post(url, params=params)
192192

193193
self._raise_for_status(res)

docker/utils/utils.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,6 @@ def datetime_to_timestamp(dt):
546546
return delta.seconds + delta.days * 24 * 3600
547547

548548

549-
def longint(n):
550-
if six.PY3:
551-
return int(n)
552-
return long(n)
553-
554-
555549
def parse_bytes(s):
556550
if isinstance(s, six.integer_types + (float,)):
557551
return s
@@ -574,15 +568,15 @@ def parse_bytes(s):
574568

575569
if suffix in units.keys() or suffix.isdigit():
576570
try:
577-
digits = longint(digits_part)
571+
digits = int(digits_part)
578572
except ValueError:
579573
raise errors.DockerException(
580574
'Failed converting the string value for memory ({0}) to'
581575
' an integer.'.format(digits_part)
582576
)
583577

584578
# Reconvert to long for the final result
585-
s = longint(digits * units[suffix])
579+
s = int(digits * units[suffix])
586580
else:
587581
raise errors.DockerException(
588582
'The specified value for memory ({0}) should specify the'

docs/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ correct value (e.g `gzip`).
109109
```
110110

111111
**Raises:** [TypeError](
112-
https://docs.python.org/3.4/library/exceptions.html#TypeError) if `path` nor
112+
https://docs.python.org/3.5/library/exceptions.html#TypeError) if `path` nor
113113
`fileobj` are specified
114114

115115
## commit
@@ -207,7 +207,7 @@ of the created container in bytes) or a string with a units identification char
207207
character, bytes are assumed as an intended unit.
208208

209209
`volumes_from` and `dns` arguments raise [TypeError](
210-
https://docs.python.org/3.4/library/exceptions.html#TypeError) exception if
210+
https://docs.python.org/3.5/library/exceptions.html#TypeError) exception if
211211
they are used against v1.10 and above of the Docker remote API. Those
212212
arguments should be passed as part of the `host_config` dictionary.
213213

docs/tls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ first.*
1212
* ca_cert (str): Path to CA cert file
1313
* verify (bool or str): This can be `False` or a path to a CA Cert file
1414
* ssl_version (int): A valid [SSL version](
15-
https://docs.python.org/3.4/library/ssl.html#ssl.PROTOCOL_TLSv1)
15+
https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1)
1616
* assert_hostname (bool): Verify hostname of docker daemon
1717

1818
### configure_client

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
':python_version < "3.3"': 'ipaddress >= 1.0.16',
1717
}
1818

19+
version = None
1920
exec(open('docker/version.py').read())
2021

2122
with open('./test-requirements.txt') as test_reqs_txt:
@@ -42,10 +43,13 @@
4243
'Intended Audience :: Developers',
4344
'Operating System :: OS Independent',
4445
'Programming Language :: Python',
46+
'Programming Language :: Python :: 2',
4547
'Programming Language :: Python :: 2.6',
4648
'Programming Language :: Python :: 2.7',
49+
'Programming Language :: Python :: 3',
4750
'Programming Language :: Python :: 3.3',
4851
'Programming Language :: Python :: 3.4',
52+
'Programming Language :: Python :: 3.5',
4953
'Topic :: Utilities',
5054
'License :: OSI Approved :: Apache Software License',
5155
],

test-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mock==1.0.1
2-
pytest==2.7.2
2+
pytest==2.9.1
33
coverage==3.7.1
44
pytest-cov==2.1.0
5-
flake8==2.4.1
5+
flake8==2.4.1

tests/unit/utils_test.py

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -299,56 +299,30 @@ def test_convert_volume_binds_no_mode(self):
299299
self.assertEqual(convert_volume_binds(data), ['/mnt/vol1:/data:rw'])
300300

301301
def test_convert_volume_binds_unicode_bytes_input(self):
302-
if six.PY2:
303-
expected = [unicode('/mnt/지연:/unicode/박:rw', 'utf-8')]
304-
305-
data = {
306-
'/mnt/지연': {
307-
'bind': '/unicode/박',
308-
'mode': 'rw'
309-
}
310-
}
311-
self.assertEqual(
312-
convert_volume_binds(data), expected
313-
)
314-
else:
315-
expected = ['/mnt/지연:/unicode/박:rw']
302+
expected = [u'/mnt/지연:/unicode/박:rw']
316303

317-
data = {
318-
bytes('/mnt/지연', 'utf-8'): {
319-
'bind': bytes('/unicode/박', 'utf-8'),
320-
'mode': 'rw'
321-
}
304+
data = {
305+
u'/mnt/지연'.encode('utf-8'): {
306+
'bind': u'/unicode/박'.encode('utf-8'),
307+
'mode': 'rw'
322308
}
323-
self.assertEqual(
324-
convert_volume_binds(data), expected
325-
)
309+
}
310+
self.assertEqual(
311+
convert_volume_binds(data), expected
312+
)
326313

327314
def test_convert_volume_binds_unicode_unicode_input(self):
328-
if six.PY2:
329-
expected = [unicode('/mnt/지연:/unicode/박:rw', 'utf-8')]
330-
331-
data = {
332-
unicode('/mnt/지연', 'utf-8'): {
333-
'bind': unicode('/unicode/박', 'utf-8'),
334-
'mode': 'rw'
335-
}
336-
}
337-
self.assertEqual(
338-
convert_volume_binds(data), expected
339-
)
340-
else:
341-
expected = ['/mnt/지연:/unicode/박:rw']
315+
expected = [u'/mnt/지연:/unicode/박:rw']
342316

343-
data = {
344-
'/mnt/지연': {
345-
'bind': '/unicode/박',
346-
'mode': 'rw'
347-
}
317+
data = {
318+
u'/mnt/지연': {
319+
'bind': u'/unicode/박',
320+
'mode': 'rw'
348321
}
349-
self.assertEqual(
350-
convert_volume_binds(data), expected
351-
)
322+
}
323+
self.assertEqual(
324+
convert_volume_binds(data), expected
325+
)
352326

353327

354328
class ParseEnvFileTest(base.BaseTestCase):
@@ -612,13 +586,7 @@ def test_create_ipam_config(self):
612586
class SplitCommandTest(base.BaseTestCase):
613587

614588
def test_split_command_with_unicode(self):
615-
if six.PY2:
616-
self.assertEqual(
617-
split_command(unicode('echo μμ', 'utf-8')),
618-
['echo', 'μμ']
619-
)
620-
else:
621-
self.assertEqual(split_command('echo μμ'), ['echo', 'μμ'])
589+
self.assertEqual(split_command(u'echo μμ'), ['echo', 'μμ'])
622590

623591
@pytest.mark.skipif(six.PY3, reason="shlex doesn't support bytes in py3")
624592
def test_split_command_with_bytes(self):

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py26, py27, py33, py34, flake8
2+
envlist = py26, py27, py33, py34, py35, flake8
33
skipsdist=True
44

55
[testenv]
@@ -11,5 +11,5 @@ deps =
1111
-r{toxinidir}/requirements.txt
1212

1313
[testenv:flake8]
14-
commands = flake8 docker tests
14+
commands = flake8 docker tests setup.py
1515
deps = flake8

0 commit comments

Comments
 (0)