Skip to content

Commit

Permalink
Drop support for Python 2.6
Browse files Browse the repository at this point in the history
Because it's ancient. If you're still using it, you can use an old
version of docker-py.

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
  • Loading branch information
bfirsh committed Nov 22, 2016
1 parent b49cacc commit d5bc7dc
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 82 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: python
python:
- "3.5"
env:
- TOX_ENV=py26
- TOX_ENV=py27
- TOX_ENV=py33
- TOX_ENV=py34
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
Expand Down
36 changes: 0 additions & 36 deletions tests/base.py

This file was deleted.

16 changes: 5 additions & 11 deletions tests/unit/api_test.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import datetime
import json
import io
import os
import re
import shutil
import socket
import sys
import tempfile
import threading
import time
import io
import unittest

import docker
import requests
from requests.packages import urllib3
import six

from .. import base
from . import fake_api

import pytest
Expand Down Expand Up @@ -93,7 +92,7 @@ def fake_read_from_socket(self, response, stream):
docker.constants.DEFAULT_DOCKER_API_VERSION)


class DockerClientTest(base.Cleanup, base.BaseTestCase):
class DockerClientTest(unittest.TestCase):
def setUp(self):
self.patcher = mock.patch.multiple(
'docker.Client', get=fake_get, post=fake_post, put=fake_put,
Expand All @@ -109,11 +108,6 @@ def tearDown(self):
self.client.close()
self.patcher.stop()

def assertIn(self, object, collection):
if six.PY2 and sys.version_info[1] <= 6:
return self.assertTrue(object in collection)
return super(DockerClientTest, self).assertIn(object, collection)

def base_create_payload(self, img='busybox', cmd=None):
if not cmd:
cmd = ['true']
Expand Down Expand Up @@ -356,7 +350,7 @@ def test_stream_helper_decoding(self):
self.assertEqual(result, content)


class StreamTest(base.Cleanup, base.BaseTestCase):
class StreamTest(unittest.TestCase):
def setUp(self):
socket_dir = tempfile.mkdtemp()
self.build_context = tempfile.mkdtemp()
Expand Down Expand Up @@ -458,7 +452,7 @@ def test_early_stream_response(self):
str(i).encode() for i in range(50)])


class UserAgentTest(base.BaseTestCase):
class UserAgentTest(unittest.TestCase):
def setUp(self):
self.patcher = mock.patch.object(
docker.Client,
Expand Down
11 changes: 5 additions & 6 deletions tests/unit/auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
import random
import shutil
import tempfile
import unittest

from docker import auth, errors

from .. import base

try:
from unittest import mock
except ImportError:
import mock


class RegressionTest(base.BaseTestCase):
class RegressionTest(unittest.TestCase):
def test_803_urlsafe_encode(self):
auth_data = {
'username': 'root',
Expand All @@ -29,7 +28,7 @@ def test_803_urlsafe_encode(self):
assert b'_' in encoded


class ResolveRepositoryNameTest(base.BaseTestCase):
class ResolveRepositoryNameTest(unittest.TestCase):
def test_resolve_repository_name_hub_library_image(self):
self.assertEqual(
auth.resolve_repository_name('image'),
Expand Down Expand Up @@ -115,7 +114,7 @@ def encode_auth(auth_info):
auth_info.get('password', '').encode('utf-8'))


class ResolveAuthTest(base.BaseTestCase):
class ResolveAuthTest(unittest.TestCase):
index_config = {'auth': encode_auth({'username': 'indexuser'})}
private_config = {'auth': encode_auth({'username': 'privateuser'})}
legacy_config = {'auth': encode_auth({'username': 'legacyauth'})}
Expand Down Expand Up @@ -270,7 +269,7 @@ def test_resolve_registry_and_auth_unauthenticated_registry(self):
)


class LoadConfigTest(base.Cleanup, base.BaseTestCase):
class LoadConfigTest(unittest.TestCase):
def test_load_config_no_file(self):
folder = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, folder)
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/client_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os
import unittest

from docker.client import Client
from .. import base

TEST_CERT_DIR = os.path.join(
os.path.dirname(__file__),
'testdata/certs',
)


class ClientTest(base.BaseTestCase):
class ClientTest(unittest.TestCase):
def setUp(self):
self.os_environ = os.environ.copy()

Expand All @@ -34,7 +35,7 @@ def test_from_env_with_version(self):
self.assertEqual(client._version, '2.32')


class DisableSocketTest(base.BaseTestCase):
class DisableSocketTest(unittest.TestCase):
class DummySocket(object):
def __init__(self, timeout=60):
self.timeout = timeout
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import six

from ..helpers import requires_api_version
from .api_test import DockerClientTest, url_prefix, response
from ..helpers import requires_api_version
from docker.utils import create_ipam_config, create_ipam_pool

try:
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/ssladapter_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import unittest
from docker import ssladapter

try:
Expand All @@ -16,10 +17,8 @@
OP_NO_SSLv3 = 0x2000000
OP_NO_TLSv1 = 0x4000000

from .. import base


class SSLAdapterTest(base.BaseTestCase):
class SSLAdapterTest(unittest.TestCase):
def test_only_uses_tls(self):
ssl_context = ssladapter.urllib3.util.ssl_.create_urllib3_context()

Expand All @@ -29,7 +28,7 @@ def test_only_uses_tls(self):
assert not ssl_context.options & OP_NO_TLSv1


class MatchHostnameTest(base.BaseTestCase):
class MatchHostnameTest(unittest.TestCase):
cert = {
'issuer': (
(('countryName', u'US'),),
Expand Down
35 changes: 17 additions & 18 deletions tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
import tarfile
import tempfile
import unittest

import pytest
import six
Expand All @@ -28,7 +29,6 @@
from docker.utils.ports import build_port_bindings, split_port
from docker.utils.utils import create_endpoint_config, format_environment

from .. import base
from ..helpers import make_tree


Expand All @@ -38,7 +38,7 @@
)


class DecoratorsTest(base.BaseTestCase):
class DecoratorsTest(unittest.TestCase):
def test_update_headers(self):
sample_headers = {
'X-Docker-Locale': 'en-US',
Expand Down Expand Up @@ -69,7 +69,7 @@ def f(self, headers=None):
}


class HostConfigTest(base.BaseTestCase):
class HostConfigTest(unittest.TestCase):
def test_create_host_config_no_options(self):
config = create_host_config(version='1.19')
self.assertFalse('NetworkMode' in config)
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_create_host_config_with_isolation(self):
)


class UlimitTest(base.BaseTestCase):
class UlimitTest(unittest.TestCase):
def test_create_host_config_dict_ulimit(self):
ulimit_dct = {'name': 'nofile', 'soft': 8096}
config = create_host_config(
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_ulimit_invalid_type(self):
self.assertRaises(ValueError, lambda: Ulimit(name='hello', hard='456'))


class LogConfigTest(base.BaseTestCase):
class LogConfigTest(unittest.TestCase):
def test_create_host_config_dict_logconfig(self):
dct = {'type': LogConfig.types.SYSLOG, 'config': {'key1': 'val1'}}
config = create_host_config(
Expand All @@ -277,7 +277,7 @@ def test_logconfig_invalid_config_type(self):
LogConfig(type=LogConfig.types.JSON, config='helloworld')


class KwargsFromEnvTest(base.BaseTestCase):
class KwargsFromEnvTest(unittest.TestCase):
def setUp(self):
self.os_environ = os.environ.copy()

Expand Down Expand Up @@ -377,7 +377,7 @@ def test_kwargs_from_env_alternate_env(self):
assert 'tls' not in kwargs


class ConverVolumeBindsTest(base.BaseTestCase):
class ConverVolumeBindsTest(unittest.TestCase):
def test_convert_volume_binds_empty(self):
self.assertEqual(convert_volume_binds({}), [])
self.assertEqual(convert_volume_binds([]), [])
Expand Down Expand Up @@ -436,7 +436,7 @@ def test_convert_volume_binds_unicode_unicode_input(self):
)


class ParseEnvFileTest(base.BaseTestCase):
class ParseEnvFileTest(unittest.TestCase):
def generate_tempfile(self, file_content=None):
"""
Generates a temporary file for tests with the content
Expand Down Expand Up @@ -479,7 +479,7 @@ def test_parse_env_file_invalid_line(self):
os.unlink(env_file)


class ParseHostTest(base.BaseTestCase):
class ParseHostTest(unittest.TestCase):
def test_parse_host(self):
invalid_hosts = [
'0.0.0.0',
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_parse_host_trailing_slash(self):
assert parse_host(host_value) == expected_result


class ParseRepositoryTagTest(base.BaseTestCase):
class ParseRepositoryTagTest(unittest.TestCase):
sha = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'

def test_index_image_no_tag(self):
Expand Down Expand Up @@ -587,7 +587,7 @@ def test_private_reg_image_sha(self):
)


class ParseDeviceTest(base.BaseTestCase):
class ParseDeviceTest(unittest.TestCase):
def test_dict(self):
devices = parse_devices([{
'PathOnHost': '/dev/sda1',
Expand Down Expand Up @@ -646,7 +646,7 @@ def test_hybrid_list(self):
})


class ParseBytesTest(base.BaseTestCase):
class ParseBytesTest(unittest.TestCase):
def test_parse_bytes_valid(self):
self.assertEqual(parse_bytes("512MB"), 536870912)
self.assertEqual(parse_bytes("512M"), 536870912)
Expand All @@ -666,7 +666,7 @@ def test_parse_bytes_maxint(self):
)


class UtilsTest(base.BaseTestCase):
class UtilsTest(unittest.TestCase):
longMessage = True

def test_convert_filters(self):
Expand Down Expand Up @@ -706,7 +706,7 @@ def test_create_ipam_config(self):
})


class SplitCommandTest(base.BaseTestCase):
class SplitCommandTest(unittest.TestCase):
def test_split_command_with_unicode(self):
self.assertEqual(split_command(u'echo μμ'), ['echo', 'μμ'])

Expand All @@ -715,7 +715,7 @@ def test_split_command_with_bytes(self):
self.assertEqual(split_command('echo μμ'), ['echo', 'μμ'])


class PortsTest(base.BaseTestCase):
class PortsTest(unittest.TestCase):
def test_split_port_with_host_ip(self):
internal_port, external_port = split_port("127.0.0.1:1000:2000")
self.assertEqual(internal_port, ["2000"])
Expand Down Expand Up @@ -821,14 +821,13 @@ def test_build_port_bindings_with_nonmatching_internal_port_ranges(self):
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
self.assertEqual(port_bindings["2000"], [("127.0.0.1", "2000")])


def convert_paths(collection):
if not IS_WINDOWS_PLATFORM:
return collection
return set(map(lambda x: x.replace('/', '\\'), collection))


class ExcludePathsTest(base.BaseTestCase):
class ExcludePathsTest(unittest.TestCase):
dirs = [
'foo',
'foo/bar',
Expand Down Expand Up @@ -1010,7 +1009,7 @@ def test_subdirectory(self):
)


class TarTest(base.Cleanup, base.BaseTestCase):
class TarTest(unittest.TestCase):
def test_tar_with_excludes(self):
dirs = [
'foo',
Expand Down
Loading

0 comments on commit d5bc7dc

Please sign in to comment.