mirror of https://github.com/docker/docker-py.git
Drop support for Python 2.6
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>
This commit is contained in:
parent
b49cacced0
commit
d5bc7dc99a
|
|
@ -3,7 +3,6 @@ language: python
|
|||
python:
|
||||
- "3.5"
|
||||
env:
|
||||
- TOX_ENV=py26
|
||||
- TOX_ENV=py27
|
||||
- TOX_ENV=py33
|
||||
- TOX_ENV=py34
|
||||
|
|
|
|||
1
setup.py
1
setup.py
|
|
@ -64,7 +64,6 @@ setup(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class BaseTestCase(unittest.TestCase):
|
||||
def assertIn(self, object, collection):
|
||||
if six.PY2 and sys.version_info[1] <= 6:
|
||||
return self.assertTrue(object in collection)
|
||||
return super(BaseTestCase, self).assertIn(object, collection)
|
||||
|
||||
|
||||
class Cleanup(object):
|
||||
if sys.version_info < (2, 7):
|
||||
# Provide a basic implementation of addCleanup for Python < 2.7
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Cleanup, self).__init__(*args, **kwargs)
|
||||
self._cleanups = []
|
||||
|
||||
def tearDown(self):
|
||||
super(Cleanup, self).tearDown()
|
||||
ok = True
|
||||
while self._cleanups:
|
||||
fn, args, kwargs = self._cleanups.pop(-1)
|
||||
try:
|
||||
fn(*args, **kwargs)
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
ok = False
|
||||
if not ok:
|
||||
raise
|
||||
|
||||
def addCleanup(self, function, *args, **kwargs):
|
||||
self._cleanups.append((function, args, kwargs))
|
||||
|
|
@ -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
|
||||
|
|
@ -93,7 +92,7 @@ url_prefix = '{0}v{1}/'.format(
|
|||
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,
|
||||
|
|
@ -109,11 +108,6 @@ class DockerClientTest(base.Cleanup, base.BaseTestCase):
|
|||
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']
|
||||
|
|
@ -356,7 +350,7 @@ class DockerApiTest(DockerClientTest):
|
|||
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()
|
||||
|
|
@ -458,7 +452,7 @@ class StreamTest(base.Cleanup, base.BaseTestCase):
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -7,18 +7,17 @@ import os.path
|
|||
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',
|
||||
|
|
@ -29,7 +28,7 @@ class RegressionTest(base.BaseTestCase):
|
|||
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'),
|
||||
|
|
@ -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'})}
|
||||
|
|
@ -270,7 +269,7 @@ class ResolveAuthTest(base.BaseTestCase):
|
|||
)
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import unittest
|
||||
|
||||
from docker.client import Client
|
||||
from .. import base
|
||||
|
||||
TEST_CERT_DIR = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
|
|
@ -8,7 +9,7 @@ TEST_CERT_DIR = os.path.join(
|
|||
)
|
||||
|
||||
|
||||
class ClientTest(base.BaseTestCase):
|
||||
class ClientTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.os_environ = os.environ.copy()
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ class ClientTest(base.BaseTestCase):
|
|||
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
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import json
|
|||
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import unittest
|
||||
from docker import ssladapter
|
||||
|
||||
try:
|
||||
|
|
@ -16,10 +17,8 @@ except ImportError:
|
|||
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()
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ class SSLAdapterTest(base.BaseTestCase):
|
|||
assert not ssl_context.options & OP_NO_TLSv1
|
||||
|
||||
|
||||
class MatchHostnameTest(base.BaseTestCase):
|
||||
class MatchHostnameTest(unittest.TestCase):
|
||||
cert = {
|
||||
'issuer': (
|
||||
(('countryName', u'US'),),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import shutil
|
|||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
import six
|
||||
|
|
@ -28,7 +29,6 @@ from docker.utils import (
|
|||
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
|
||||
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ TEST_CERT_DIR = os.path.join(
|
|||
)
|
||||
|
||||
|
||||
class DecoratorsTest(base.BaseTestCase):
|
||||
class DecoratorsTest(unittest.TestCase):
|
||||
def test_update_headers(self):
|
||||
sample_headers = {
|
||||
'X-Docker-Locale': 'en-US',
|
||||
|
|
@ -69,7 +69,7 @@ class DecoratorsTest(base.BaseTestCase):
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -208,7 +208,7 @@ class HostConfigTest(base.BaseTestCase):
|
|||
)
|
||||
|
||||
|
||||
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(
|
||||
|
|
@ -253,7 +253,7 @@ class UlimitTest(base.BaseTestCase):
|
|||
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(
|
||||
|
|
@ -277,7 +277,7 @@ class LogConfigTest(base.BaseTestCase):
|
|||
LogConfig(type=LogConfig.types.JSON, config='helloworld')
|
||||
|
||||
|
||||
class KwargsFromEnvTest(base.BaseTestCase):
|
||||
class KwargsFromEnvTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.os_environ = os.environ.copy()
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ class KwargsFromEnvTest(base.BaseTestCase):
|
|||
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([]), [])
|
||||
|
|
@ -436,7 +436,7 @@ class ConverVolumeBindsTest(base.BaseTestCase):
|
|||
)
|
||||
|
||||
|
||||
class ParseEnvFileTest(base.BaseTestCase):
|
||||
class ParseEnvFileTest(unittest.TestCase):
|
||||
def generate_tempfile(self, file_content=None):
|
||||
"""
|
||||
Generates a temporary file for tests with the content
|
||||
|
|
@ -479,7 +479,7 @@ class ParseEnvFileTest(base.BaseTestCase):
|
|||
os.unlink(env_file)
|
||||
|
||||
|
||||
class ParseHostTest(base.BaseTestCase):
|
||||
class ParseHostTest(unittest.TestCase):
|
||||
def test_parse_host(self):
|
||||
invalid_hosts = [
|
||||
'0.0.0.0',
|
||||
|
|
@ -541,7 +541,7 @@ class ParseHostTest(base.BaseTestCase):
|
|||
assert parse_host(host_value) == expected_result
|
||||
|
||||
|
||||
class ParseRepositoryTagTest(base.BaseTestCase):
|
||||
class ParseRepositoryTagTest(unittest.TestCase):
|
||||
sha = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
||||
|
||||
def test_index_image_no_tag(self):
|
||||
|
|
@ -587,7 +587,7 @@ class ParseRepositoryTagTest(base.BaseTestCase):
|
|||
)
|
||||
|
||||
|
||||
class ParseDeviceTest(base.BaseTestCase):
|
||||
class ParseDeviceTest(unittest.TestCase):
|
||||
def test_dict(self):
|
||||
devices = parse_devices([{
|
||||
'PathOnHost': '/dev/sda1',
|
||||
|
|
@ -646,7 +646,7 @@ class ParseDeviceTest(base.BaseTestCase):
|
|||
})
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -666,7 +666,7 @@ class ParseBytesTest(base.BaseTestCase):
|
|||
)
|
||||
|
||||
|
||||
class UtilsTest(base.BaseTestCase):
|
||||
class UtilsTest(unittest.TestCase):
|
||||
longMessage = True
|
||||
|
||||
def test_convert_filters(self):
|
||||
|
|
@ -706,7 +706,7 @@ class UtilsTest(base.BaseTestCase):
|
|||
})
|
||||
|
||||
|
||||
class SplitCommandTest(base.BaseTestCase):
|
||||
class SplitCommandTest(unittest.TestCase):
|
||||
def test_split_command_with_unicode(self):
|
||||
self.assertEqual(split_command(u'echo μμ'), ['echo', 'μμ'])
|
||||
|
||||
|
|
@ -715,7 +715,7 @@ class SplitCommandTest(base.BaseTestCase):
|
|||
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"])
|
||||
|
|
@ -821,14 +821,13 @@ class PortsTest(base.BaseTestCase):
|
|||
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',
|
||||
|
|
@ -1010,7 +1009,7 @@ class ExcludePathsTest(base.BaseTestCase):
|
|||
)
|
||||
|
||||
|
||||
class TarTest(base.Cleanup, base.BaseTestCase):
|
||||
class TarTest(unittest.TestCase):
|
||||
def test_tar_with_excludes(self):
|
||||
dirs = [
|
||||
'foo',
|
||||
|
|
|
|||
Loading…
Reference in New Issue