Skip to content

Commit e0b9cb2

Browse files
author
Thomas Grainger
committed
support Python 3.5
Signed-off-by: Thomas Grainger <[email protected]>
1 parent 26f2b69 commit e0b9cb2

File tree

6 files changed

+31
-64
lines changed

6 files changed

+31
-64
lines changed

.travis.yml

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

docker/utils/utils.py

+2-8
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'

setup.py

+4
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

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

+19-51
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

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