Skip to content

Commit e2ac293

Browse files
committed
Merge pull request #280 from emonty/remove_auth_from_tests
Protect push tests from environment
2 parents 8e45264 + 5f2c3de commit e2ac293

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/test.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def response(status_code=200, content='', headers=None, reason=None, elapsed=0,
5252
return res
5353

5454

55+
def fake_resolve_authconfig(authconfig, registry=None):
56+
return None
57+
58+
5559
def fake_resp(url, data=None, **kwargs):
5660
status_code, content = fake_api.fake_responses[url]()
5761
return response(status_code=status_code, content=content)
@@ -1202,7 +1206,9 @@ def test_insert_image(self):
12021206

12031207
def test_push_image(self):
12041208
try:
1205-
self.client.push(fake_api.FAKE_IMAGE_NAME)
1209+
with mock.patch('docker.auth.auth.resolve_authconfig',
1210+
fake_resolve_authconfig):
1211+
self.client.push(fake_api.FAKE_IMAGE_NAME)
12061212
except Exception as e:
12071213
self.fail('Command should not raise exception: {0}'.format(e))
12081214

@@ -1216,7 +1222,9 @@ def test_push_image(self):
12161222

12171223
def test_push_image_stream(self):
12181224
try:
1219-
self.client.push(fake_api.FAKE_IMAGE_NAME, stream=True)
1225+
with mock.patch('docker.auth.auth.resolve_authconfig',
1226+
fake_resolve_authconfig):
1227+
self.client.push(fake_api.FAKE_IMAGE_NAME, stream=True)
12201228
except Exception as e:
12211229
self.fail('Command should not raise exception: {0}'.format(e))
12221230

0 commit comments

Comments
 (0)