Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 1422dc8

Browse files
Pierre Chaussaletjohanneswuerbach
authored andcommitted
Fix code formatting and removes useless imports
1 parent a5c0ad7 commit 1422dc8

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

docker_registry/drivers/s3.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
gevent.monkey.patch_all()
1212

1313
import docker_registry.core.boto as coreboto
14-
from docker_registry.core import exceptions
1514
from docker_registry.core import compat
15+
from docker_registry.core import exceptions
1616
from docker_registry.core import lru
1717

1818
import logging
@@ -147,12 +147,12 @@ def content_redirect_url(self, path):
147147
# Have cloudfront? Sign it
148148
return self.signer(path, expire_time=60)
149149

150-
def get_content(self, path, tries = 0):
150+
def get_content(self, path, tries=0):
151151
try:
152152
return super(Storage, self).get_content(path)
153-
except exceptions.FileNotFoundError, e:
153+
except exceptions.FileNotFoundError as e:
154154
if tries <= 3:
155155
time.sleep(.1)
156-
return self.get_content(path, tries+1)
156+
return self.get_content(path, tries + 1)
157157
else:
158158
raise e

tests/test_s3.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from docker_registry.core import exceptions
1111
import docker_registry.testing as testing
12-
import docker_registry.testing.mock_boto as mock_boto
13-
from docker_registry.drivers import s3
1412

1513
from docker_registry.testing import mock_boto # noqa
1614

@@ -145,31 +143,34 @@ def test_get_tags(self):
145143
def test_consistency_latency(self):
146144
self.testCount = -1
147145
mockKey = mock_boto.Key()
146+
148147
def mockExists():
149148
self.testCount += 1
150149
return self.testCount == 1
151150
mockKey.exists = mockExists
152151
mockKey.get_contents_as_string = lambda: "Foo bar"
153-
storage = s3.Storage(self.path, self.config)
154-
storage.makeKey = lambda x: mockKey
152+
self._storage.makeKey = lambda x: mockKey
155153
startTime = time.time()
156154

157-
content = storage.get_content("/FOO")
155+
content = self._storage.get_content("/FOO")
158156

159157
waitTime = time.time() - startTime
160-
assert waitTime >= 0.1, "Waiting time was less than %sms (actual : %sms)" % (0.1*1000, waitTime*1000)
161-
assert content == "Foo bar", "expected : %s; actual: %s" % ("Foo bar", content)
158+
assert waitTime >= 0.1, "Waiting time was less than %sms " \
159+
"(actual : %sms)" % \
160+
(0.1 * 1000, waitTime * 1000)
161+
assert content == "Foo bar", "expected : %s; actual: %s" % \
162+
("Foo bar", content)
162163

163164
@tools.raises(exceptions.FileNotFoundError)
164165
def test_too_many_read_retries(self):
165166
self.testCount = -1
166167
mockKey = mock_boto.Key()
168+
167169
def mockExists():
168170
self.testCount += 1
169171
return self.testCount == 5
170172
mockKey.exists = mockExists
171173
mockKey.get_contents_as_string = lambda: "Foo bar"
172-
storage = s3.Storage(self.path, self.config)
173-
storage.makeKey = lambda x: mockKey
174+
self._storage.makeKey = lambda x: mockKey
174175

175-
storage.get_content("/FOO")
176+
self._storage.get_content("/FOO")

0 commit comments

Comments
 (0)