Fixed py26 errors related to using assert_raises in tests.
This commit is contained in:
parent
665beda466
commit
bf996f1461
@ -295,7 +295,6 @@ class IAMBackend(BaseBackend):
|
||||
except KeyError:
|
||||
raise BotoServerError(404, 'Not Found')
|
||||
|
||||
print('username={}'.format(key.user_name))
|
||||
return key
|
||||
|
||||
def get_all_access_keys(self, user_name, marker=None, max_items=None):
|
||||
|
@ -66,7 +66,8 @@ def test_create_role_and_instance_profile():
|
||||
def test_create_group():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_group('my-group')
|
||||
assert_raises(BotoServerError, conn.create_group, 'my-group')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_group('my-group')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
@ -74,20 +75,23 @@ def test_get_group():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_group('my-group')
|
||||
conn.get_group('my-group')
|
||||
assert_raises(BotoServerError, conn.get_group, 'not-group')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.get_group('not-group')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_create_user():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_user('my-user')
|
||||
assert_raises(BotoServerError, conn.create_user, 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_user('my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_get_user():
|
||||
conn = boto.connect_iam()
|
||||
assert_raises(BotoServerError, conn.get_user, 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.get_user('my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.get_user('my-user')
|
||||
|
||||
@ -95,9 +99,11 @@ def test_get_user():
|
||||
@mock_iam()
|
||||
def test_add_user_to_group():
|
||||
conn = boto.connect_iam()
|
||||
assert_raises(BotoServerError, conn.add_user_to_group, 'my-group', 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
conn.create_group('my-group')
|
||||
assert_raises(BotoServerError, conn.add_user_to_group, 'my-group', 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
|
||||
@ -105,10 +111,12 @@ def test_add_user_to_group():
|
||||
@mock_iam()
|
||||
def test_remove_user_from_group():
|
||||
conn = boto.connect_iam()
|
||||
assert_raises(BotoServerError, conn.remove_user_from_group, 'my-group', 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.remove_user_from_group('my-group', 'my-user')
|
||||
conn.create_group('my-group')
|
||||
conn.create_user('my-user')
|
||||
assert_raises(BotoServerError, conn.remove_user_from_group, 'my-group', 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.remove_user_from_group('my-group', 'my-user')
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
conn.remove_user_from_group('my-group', 'my-user')
|
||||
|
||||
@ -116,7 +124,8 @@ def test_remove_user_from_group():
|
||||
@mock_iam()
|
||||
def test_create_access_key():
|
||||
conn = boto.connect_iam()
|
||||
assert_raises(BotoServerError, conn.create_access_key, 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_access_key('my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.create_access_key('my-user')
|
||||
|
||||
@ -149,6 +158,7 @@ def test_delete_access_key():
|
||||
@mock_iam()
|
||||
def test_delete_user():
|
||||
conn = boto.connect_iam()
|
||||
assert_raises(BotoServerError, conn.delete_user, 'my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.delete_user('my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.delete_user('my-user')
|
||||
|
Loading…
Reference in New Issue
Block a user