Kaydet (Commit) 1ce8dc96 authored tarafından Deni Bertovic's avatar Deni Bertovic

python3 fixes

Fixed imports to be compatible with python3 on various places in the client lib
and in the tests themselves.
üst 7fbc41ea
...@@ -13,4 +13,3 @@ ...@@ -13,4 +13,3 @@
# limitations under the License. # limitations under the License.
from .client import Client, APIError from .client import Client, APIError
import auth
...@@ -18,7 +18,7 @@ import os ...@@ -18,7 +18,7 @@ import os
import six import six
import utils from .utils import ping
INDEX_URL = 'https://index.docker.io/v1/' INDEX_URL = 'https://index.docker.io/v1/'
...@@ -35,7 +35,7 @@ def expand_registry_url(hostname): ...@@ -35,7 +35,7 @@ def expand_registry_url(hostname):
if '/' not in hostname[9:]: if '/' not in hostname[9:]:
hostname = hostname + '/v1/' hostname = hostname + '/v1/'
return hostname return hostname
if utils.ping('https://' + hostname + '_ping'): if ping('https://' + hostname + '_ping'):
return 'https://' + hostname + '/v1/' return 'https://' + hostname + '/v1/'
return 'http://' + hostname + '/v1/' return 'http://' + hostname + '/v1/'
......
...@@ -20,9 +20,11 @@ import requests ...@@ -20,9 +20,11 @@ import requests
import requests.exceptions import requests.exceptions
import six import six
import auth from .auth import (load_config, resolve_repository_name,
import unixconn resolve_authconfig, encode_header)
import utils
from .unixconn import UnixAdapter
from .utils import tar, compare_version, mkbuildcontext
class APIError(requests.exceptions.HTTPError): class APIError(requests.exceptions.HTTPError):
...@@ -60,11 +62,11 @@ class APIError(requests.exceptions.HTTPError): ...@@ -60,11 +62,11 @@ class APIError(requests.exceptions.HTTPError):
class Client(requests.Session): class Client(requests.Session):
def __init__(self, base_url="unix://var/run/docker.sock", version="1.4"): def __init__(self, base_url="unix://var/run/docker.sock", version="1.4"):
super(Client, self).__init__() super(Client, self).__init__()
self.mount('unix://', unixconn.UnixAdapter(base_url)) self.mount('unix://', UnixAdapter(base_url))
self.base_url = base_url self.base_url = base_url
self._version = version self._version = version
try: try:
self._cfg = auth.load_config() self._cfg = load_config()
except Exception: except Exception:
pass pass
...@@ -172,12 +174,12 @@ class Client(requests.Session): ...@@ -172,12 +174,12 @@ class Client(requests.Session):
raise Exception("Either path or fileobj needs to be provided.") raise Exception("Either path or fileobj needs to be provided.")
if fileobj is not None: if fileobj is not None:
context = utils.mkbuildcontext(fileobj) context = mkbuildcontext(fileobj)
elif (path.startswith('http://') or path.startswith('https://') or elif (path.startswith('http://') or path.startswith('https://') or
path.startswith('git://') or path.startswith('github.com/')): path.startswith('git://') or path.startswith('github.com/')):
remote = path remote = path
else: else:
context = utils.tar(path) context = tar(path)
u = self._url('/build') u = self._url('/build')
params = { 't': tag, 'remote': remote, 'q': quiet, 'nocache': nocache, 'rm': rm } params = { 't': tag, 'remote': remote, 'q': quiet, 'nocache': nocache, 'rm': rm }
...@@ -336,7 +338,7 @@ class Client(requests.Session): ...@@ -336,7 +338,7 @@ class Client(requests.Session):
registry = auth.INDEX_URL registry = auth.INDEX_URL
if getattr(self, '_cfg', None) is None: if getattr(self, '_cfg', None) is None:
self._cfg = auth.load_config() self._cfg = auth.load_config()
authcfg = auth.resolve_authconfig(self._cfg, registry) authcfg = resolve_authconfig(self._cfg, registry)
if 'username' in authcfg and authcfg['username'] == username: if 'username' in authcfg and authcfg['username'] == username:
return authcfg return authcfg
req_data = { req_data = {
...@@ -376,7 +378,7 @@ class Client(requests.Session): ...@@ -376,7 +378,7 @@ class Client(requests.Session):
return f_port return f_port
def pull(self, repository, tag=None): def pull(self, repository, tag=None):
registry, repo_name = auth.resolve_repository_name(repository) registry, repo_name = resolve_repository_name(repository)
if repo_name.count(":") == 1: if repo_name.count(":") == 1:
repository, tag = repository.rsplit(":", 1) repository, tag = repository.rsplit(":", 1)
...@@ -385,29 +387,30 @@ class Client(requests.Session): ...@@ -385,29 +387,30 @@ class Client(requests.Session):
'fromImage': repository 'fromImage': repository
} }
headers = {} headers = {}
if utils.compare_version('1.5', self._version) >= 0:
if compare_version('1.5', self._version) >= 0:
if getattr(self, '_cfg', None) is None: if getattr(self, '_cfg', None) is None:
self._cfg = auth.load_config() self._cfg = load_config()
authcfg = auth.resolve_authconfig(self._cfg, registry) authcfg = resolve_authconfig(self._cfg, registry)
# do not fail if no atuhentication exists # do not fail if no atuhentication exists
# for this specific registry as we can have a readonly pull # for this specific registry as we can have a readonly pull
if authcfg: if authcfg:
headers['X-Registry-Auth'] = auth.encode_header(authcfg) headers['X-Registry-Auth'] = encode_header(authcfg)
u = self._url("/images/create") u = self._url("/images/create")
return self._result(self.post(u, params=params, headers=headers)) return self._result(self.post(u, params=params, headers=headers))
def push(self, repository): def push(self, repository):
registry, repository = auth.resolve_repository_name(repository) registry, repository = resolve_repository_name(repository)
u = self._url("/images/{0}/push".format(repository)) u = self._url("/images/{0}/push".format(repository))
headers = {} headers = {}
if getattr(self, '_cfg', None) is None: if getattr(self, '_cfg', None) is None:
self._cfg = auth.load_config() self._cfg = load_config()
authcfg = auth.resolve_authconfig(self._cfg, registry) authcfg = resolve_authconfig(self._cfg, registry)
if utils.compare_version('1.5', self._version) >= 0: if compare_version('1.5', self._version) >= 0:
# do not fail if no atuhentication exists # do not fail if no atuhentication exists
# for this specific registry as we can have an anon push # for this specific registry as we can have an anon push
if authcfg: if authcfg:
headers['X-Registry-Auth'] = auth.encode_header(authcfg) headers['X-Registry-Auth'] = encode_header(authcfg)
return self._result(self._post_json(u, None, headers=headers)) return self._result(self._post_json(u, None, headers=headers))
return self._result(self._post_json(u, authcfg)) return self._result(self._post_json(u, authcfg))
......
...@@ -11,8 +11,12 @@ ...@@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import six
import httplib if six.PY3:
from http import client as httplib
else:
import httplib
import requests.adapters import requests.adapters
import socket import socket
......
...@@ -32,10 +32,10 @@ except ImportError: ...@@ -32,10 +32,10 @@ except ImportError:
from io import StringIO from io import StringIO
try: if six.PY3:
import mock
except ImportError:
from unittest import mock from unittest import mock
else:
import mock
# FIXME: missing tests for # FIXME: missing tests for
...@@ -75,7 +75,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -75,7 +75,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.version() self.client.version()
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/version') fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/version')
...@@ -83,7 +83,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -83,7 +83,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.info() self.client.info()
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/info') fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/info')
...@@ -91,7 +91,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -91,7 +91,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.search('busybox') self.client.search('busybox')
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/search', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/search',
params={'term': 'busybox'}) params={'term': 'busybox'})
...@@ -104,7 +104,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -104,7 +104,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.images(all=True) self.client.images(all=True)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/json', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/json',
params={'filter': None, 'only_ids': 0, 'all': 1}) params={'filter': None, 'only_ids': 0, 'all': 1})
...@@ -112,7 +112,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -112,7 +112,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.images(quiet=True) self.client.images(quiet=True)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/json', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/json',
params={'filter': None, 'only_ids': 1, 'all': 0}) params={'filter': None, 'only_ids': 1, 'all': 0})
...@@ -121,7 +121,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -121,7 +121,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.containers(all=True) self.client.containers(all=True)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/ps', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/ps',
params={ params={
...@@ -142,7 +142,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -142,7 +142,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.create_container('busybox', 'true') self.client.create_container('busybox', 'true')
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/create', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/create',
'{"Tty": false, "Image": "busybox", "Cmd": ["true"], "AttachStdin": false, "Memory": 0, "AttachStderr": true, "Privileged": false, "AttachStdout": true, "OpenStdin": false}', '{"Tty": false, "Image": "busybox", "Cmd": ["true"], "AttachStdin": false, "Memory": 0, "AttachStderr": true, "Privileged": false, "AttachStdout": true, "OpenStdin": false}',
...@@ -156,7 +156,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -156,7 +156,7 @@ class DockerClientTest(unittest.TestCase):
self.client.create_container('busybox', self.client.create_container('busybox',
['ls', mount_dest], volumes={mount_dest: {}}) ['ls', mount_dest], volumes={mount_dest: {}})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/create', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/create',
'{"Tty": false, "Image": "busybox", "Cmd": ["ls", "/mnt"], "AttachStdin": false, "Volumes": {"/mnt": {}}, "Memory": 0, "AttachStderr": true, "Privileged": false, "AttachStdout": true, "OpenStdin": false}', '{"Tty": false, "Image": "busybox", "Cmd": ["ls", "/mnt"], "AttachStdin": false, "Volumes": {"/mnt": {}}, "Memory": 0, "AttachStderr": true, "Privileged": false, "AttachStdout": true, "OpenStdin": false}',
...@@ -166,7 +166,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -166,7 +166,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.create_container('busybox', 'true', privileged=True) self.client.create_container('busybox', 'true', privileged=True)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/create', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/containers/create',
'{"Tty": false, "Image": "busybox", "Cmd": ["true"], "AttachStdin": false, "Memory": 0, "AttachStderr": true, "Privileged": true, "AttachStdout": true, "OpenStdin": false}', '{"Tty": false, "Image": "busybox", "Cmd": ["true"], "AttachStdin": false, "Memory": 0, "AttachStderr": true, "Privileged": true, "AttachStdout": true, "OpenStdin": false}',
...@@ -176,7 +176,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -176,7 +176,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.start(FAKE_CONTAINER_ID) self.client.start(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/start', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/start',
...@@ -190,7 +190,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -190,7 +190,7 @@ class DockerClientTest(unittest.TestCase):
mount_origin = '/tmp' mount_origin = '/tmp'
self.client.start(FAKE_CONTAINER_ID, binds={mount_origin: mount_dest}) self.client.start(FAKE_CONTAINER_ID, binds={mount_origin: mount_dest})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/start', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/start',
...@@ -202,7 +202,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -202,7 +202,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.start({'Id': FAKE_CONTAINER_ID}) self.client.start({'Id': FAKE_CONTAINER_ID})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/start', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/start',
'{}', headers={'Content-Type': 'application/json'} '{}', headers={'Content-Type': 'application/json'}
...@@ -212,7 +212,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -212,7 +212,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.wait(FAKE_CONTAINER_ID) self.client.wait(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/wait', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/wait',
...@@ -224,7 +224,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -224,7 +224,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.wait({'Id': FAKE_CONTAINER_ID}) self.client.wait({'Id': FAKE_CONTAINER_ID})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/wait', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/wait',
...@@ -236,7 +236,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -236,7 +236,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.logs(FAKE_CONTAINER_ID) self.client.logs(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/attach', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/attach',
...@@ -248,7 +248,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -248,7 +248,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.logs({'Id': FAKE_CONTAINER_ID}) self.client.logs({'Id': FAKE_CONTAINER_ID})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/attach', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/attach',
...@@ -260,7 +260,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -260,7 +260,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.diff(FAKE_CONTAINER_ID) self.client.diff(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/changes') 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/changes')
...@@ -269,7 +269,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -269,7 +269,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.diff({'Id': FAKE_CONTAINER_ID}) self.client.diff({'Id': FAKE_CONTAINER_ID})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/changes') 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/changes')
...@@ -278,7 +278,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -278,7 +278,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.stop(FAKE_CONTAINER_ID, timeout=2) self.client.stop(FAKE_CONTAINER_ID, timeout=2)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/stop', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/stop',
...@@ -290,7 +290,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -290,7 +290,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.stop({'Id': FAKE_CONTAINER_ID}, timeout=2) self.client.stop({'Id': FAKE_CONTAINER_ID}, timeout=2)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/stop', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/stop',
...@@ -302,7 +302,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -302,7 +302,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.kill(FAKE_CONTAINER_ID) self.client.kill(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/kill', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/kill',
...@@ -313,7 +313,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -313,7 +313,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.kill({'Id': FAKE_CONTAINER_ID}) self.client.kill({'Id': FAKE_CONTAINER_ID})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/kill', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/kill',
...@@ -324,7 +324,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -324,7 +324,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.restart(FAKE_CONTAINER_ID, timeout=2) self.client.restart(FAKE_CONTAINER_ID, timeout=2)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception : ' + str(e)) self.fail('Command should not raise exception : {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/restart', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/restart',
...@@ -336,7 +336,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -336,7 +336,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.restart({'Id': FAKE_CONTAINER_ID}, timeout=2) self.client.restart({'Id': FAKE_CONTAINER_ID}, timeout=2)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/restart', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b/restart',
...@@ -348,7 +348,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -348,7 +348,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.remove_container(FAKE_CONTAINER_ID) self.client.remove_container(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b',
...@@ -359,7 +359,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -359,7 +359,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.remove_container({'Id': FAKE_CONTAINER_ID}) self.client.remove_container({'Id': FAKE_CONTAINER_ID})
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b', 'unix://var/run/docker.sock/v1.4/containers/3cc2351ab11b',
...@@ -374,7 +374,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -374,7 +374,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.pull('joffrey/test001') self.client.pull('joffrey/test001')
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/create', fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/create',
headers={}, headers={},
...@@ -385,7 +385,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -385,7 +385,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.commit(FAKE_CONTAINER_ID) self.client.commit(FAKE_CONTAINER_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
'unix://var/run/docker.sock/v1.4/commit', 'unix://var/run/docker.sock/v1.4/commit',
...@@ -404,7 +404,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -404,7 +404,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.remove_image(FAKE_IMAGE_ID) self.client.remove_image(FAKE_IMAGE_ID)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/e9aa60c60128') fake_request.assert_called_with('unix://var/run/docker.sock/v1.4/images/e9aa60c60128')
...@@ -423,7 +423,7 @@ class DockerClientTest(unittest.TestCase): ...@@ -423,7 +423,7 @@ class DockerClientTest(unittest.TestCase):
try: try:
self.client.build(fileobj=script) self.client.build(fileobj=script)
except Exception as e: except Exception as e:
self.fail('Command should not raise exception: ' + str(e)) self.fail('Command should not raise exception: {0}'.format(e))
####################### #######################
## PY SPECIFIC TESTS ## ## PY SPECIFIC TESTS ##
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment