summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2015-08-04 13:27:22 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-08-04 16:20:46 +0200
commit872aa0d01d1642f9c8fc204d4c33e5c5640c3352 (patch)
treef51e83bf36f05c3a93017b55d0141a7924061dbb
parent2ab9822a792e26e9ddb47cbb6bc788a0727c8556 (diff)
downloadsssd-872aa0d01d1642f9c8fc204d4c33e5c5640c3352.tar.gz
sssd-872aa0d01d1642f9c8fc204d4c33e5c5640c3352.tar.xz
sssd-872aa0d01d1642f9c8fc204d4c33e5c5640c3352.zip
intg: Modernize 'except' clauses
The 'as' syntax works from Python 2 on, and Python 3 dropped the "comma" syntax. Reviewed-by: Christian Heimes <cheimes@redhat.com>
-rw-r--r--src/tests/intg/ds_openldap.py2
-rw-r--r--src/tests/intg/ent.py16
-rw-r--r--src/tests/intg/ent_test.py74
3 files changed, 46 insertions, 46 deletions
diff --git a/src/tests/intg/ds_openldap.py b/src/tests/intg/ds_openldap.py
index c58e53a2a..42a2c9003 100644
--- a/src/tests/intg/ds_openldap.py
+++ b/src/tests/intg/ds_openldap.py
@@ -271,7 +271,7 @@ class DSOpenLDAP(DS):
if ++attempt > 30:
raise Exception("Failed to stop slapd")
time.sleep(1)
- except IOError, e:
+ except IOError as e:
if e.errno != errno.ENOENT:
raise
diff --git a/src/tests/intg/ent.py b/src/tests/intg/ent.py
index 13feaaf04..b3c412122 100644
--- a/src/tests/intg/ent.py
+++ b/src/tests/intg/ent.py
@@ -206,7 +206,7 @@ def assert_passwd_by_name(name, pattern):
"""Assert a passwd entry, retrieved by name, matches a pattern."""
try:
ent = get_passwd_by_name(name)
- except KeyError, err:
+ except KeyError as err:
assert False, err
d = _diff(ent, pattern)
assert not d, d
@@ -215,7 +215,7 @@ def assert_passwd_by_uid(uid, pattern):
"""Assert a passwd entry, retrieved by UID, matches a pattern."""
try:
ent = get_passwd_by_uid(uid)
- except KeyError, err:
+ except KeyError as err:
assert False, err
d = _diff(ent, pattern)
assert not d, d
@@ -241,7 +241,7 @@ def _diff_each_passwd_by_name(pattern_dict):
"""
try:
ent = dict((k, get_passwd_by_name(k)) for k in pattern_dict.keys())
- except KeyError, err:
+ except KeyError as err:
return str(err)
return _diff(ent, pattern_dict, _PASSWD_LIST_DESC)
@@ -252,7 +252,7 @@ def _diff_each_passwd_by_uid(pattern_dict):
"""
try:
ent = dict((k, get_passwd_by_uid(k)) for k in pattern_dict.keys())
- except KeyError, err:
+ except KeyError as err:
return str(err)
return _diff(ent, pattern_dict, _PASSWD_LIST_DESC)
@@ -349,7 +349,7 @@ def assert_group_by_name(name, pattern):
"""Assert a group entry, retrieved by name, matches a pattern."""
try:
ent = get_group_by_name(name)
- except KeyError, err:
+ except KeyError as err:
assert False, err
d = _diff(ent, pattern, _GROUP_DESC)
assert not d, d
@@ -358,7 +358,7 @@ def assert_group_by_gid(gid, pattern):
"""Assert a group entry, retrieved by GID, matches a pattern."""
try:
ent = get_group_by_gid(gid)
- except KeyError, err:
+ except KeyError as err:
assert False, err
d = _diff(ent, pattern, _GROUP_DESC)
assert not d, d
@@ -384,7 +384,7 @@ def _diff_each_group_by_name(pattern_dict):
"""
try:
ent = dict((k, get_group_by_name(k)) for k in pattern_dict.keys())
- except KeyError, err:
+ except KeyError as err:
return str(err)
return _diff(ent, pattern_dict, _GROUP_LIST_DESC)
@@ -395,7 +395,7 @@ def _diff_each_group_by_gid(pattern_dict):
"""
try:
ent = dict((k, get_group_by_gid(k)) for k in pattern_dict.keys())
- except KeyError, err:
+ except KeyError as err:
return str(err)
return _diff(ent, pattern_dict, _GROUP_LIST_DESC)
diff --git a/src/tests/intg/ent_test.py b/src/tests/intg/ent_test.py
index 896fcbe14..a50e82dd5 100644
--- a/src/tests/intg/ent_test.py
+++ b/src/tests/intg/ent_test.py
@@ -102,13 +102,13 @@ def test_assert_passwd_by_name(users_and_groups):
try:
ent.assert_passwd_by_name("user3", {})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
try:
ent.assert_passwd_by_name("user2", dict(name="user1"))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'name' mismatch: 'user1' != 'user2'"
def test_assert_passwd_by_uid(users_and_groups):
@@ -119,13 +119,13 @@ def test_assert_passwd_by_uid(users_and_groups):
try:
ent.assert_passwd_by_uid(1003, {})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getpwuid(): uid not found: 1003'"
try:
ent.assert_passwd_by_uid(1002, dict(name="user1"))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'name' mismatch: 'user1' != 'user2'"
@@ -136,13 +136,13 @@ def test_assert_passwd_list(users_and_groups):
try:
ent.assert_passwd_list(ent.contains_only())
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert not re.search("expected users not found:", str(e))
assert re.search("unexpected users found:", str(e))
try:
ent.assert_passwd_list(ent.contains(dict(name="non_existent")))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("expected users not found:", str(e))
assert not re.search("unexpected users found:", str(e))
@@ -153,12 +153,12 @@ def test_assert_each_passwd_by_name(users_and_groups):
try:
ent.assert_each_passwd_by_name(dict(user3={}))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
try:
ent.assert_each_passwd_by_name(dict(user1=dict(name="user2")))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"user 'user1' mismatch: 'name' mismatch: 'user2' != 'user1'"
@@ -169,12 +169,12 @@ def test_assert_each_passwd_by_uid(users_and_groups):
try:
ent.assert_each_passwd_by_uid({1003:{}})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getpwuid(): uid not found: 1003'"
try:
ent.assert_each_passwd_by_uid({1001:dict(uid=1002)})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"user 1001 mismatch: 'uid' mismatch: 1002 != 1001"
@@ -185,12 +185,12 @@ def test_assert_each_passwd_with_name(users_and_groups):
try:
ent.assert_each_passwd_with_name([dict(name="user3")])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
try:
ent.assert_each_passwd_with_name([dict(name="user1", uid=1002)])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"user 'user1' mismatch: 'uid' mismatch: 1002 != 1001"
@@ -201,12 +201,12 @@ def test_assert_each_passwd_with_uid(users_and_groups):
try:
ent.assert_each_passwd_with_uid([dict(uid=1003)])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getpwuid(): uid not found: 1003'"
try:
ent.assert_each_passwd_with_uid([dict(name="user2", uid=1001)])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"user 1001 mismatch: 'name' mismatch: 'user2' != 'user1'"
@@ -217,14 +217,14 @@ def test_assert_passwd(users_and_groups):
try:
ent.assert_passwd(ent.contains(dict(name="user3", uid=1003)))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("list mismatch:", str(e))
assert re.search("expected users not found:", str(e))
assert not re.search("unexpected users found:", str(e))
try:
ent.assert_passwd(ent.contains_only(USER1))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("list mismatch:", str(e))
assert not re.search("expected users not found:", str(e))
assert re.search("unexpected users found:", str(e))
@@ -235,7 +235,7 @@ def test_group_member_matching(users_and_groups):
try:
ent.assert_group_by_name("empty_group",
dict(mem=ent.contains("user1")))
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("member list mismatch:", str(e))
assert re.search("expected members not found:", str(e))
@@ -247,21 +247,21 @@ def test_group_member_matching(users_and_groups):
try:
ent.assert_group_by_name("one_user_group1",
dict(mem=ent.contains_only()))
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("member list mismatch:", str(e))
assert re.search("unexpected members found:", str(e))
assert not re.search("expected members not found:", str(e))
try:
ent.assert_group_by_name("one_user_group1",
dict(mem=ent.contains_only("user3")))
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("member list mismatch:", str(e))
assert re.search("unexpected members found:", str(e))
assert re.search("expected members not found:", str(e))
try:
ent.assert_group_by_name("one_user_group1",
dict(mem=ent.contains("user3")))
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("member list mismatch:", str(e))
assert not re.search("unexpected members found:", str(e))
assert re.search("expected members not found:", str(e))
@@ -276,7 +276,7 @@ def test_group_member_matching(users_and_groups):
try:
ent.assert_group_by_name("two_user_group",
dict(mem=ent.contains_only("user1")))
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("member list mismatch:", str(e))
assert re.search("unexpected members found:", str(e))
assert not re.search("expected members not found:", str(e))
@@ -289,13 +289,13 @@ def test_assert_group_by_name(users_and_groups):
try:
ent.assert_group_by_name("group3", {})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
try:
ent.assert_group_by_name("group2", dict(name="group1"))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'name' mismatch: 'group1' != 'group2'"
def test_assert_group_by_gid(users_and_groups):
@@ -306,13 +306,13 @@ def test_assert_group_by_gid(users_and_groups):
try:
ent.assert_group_by_gid(2003, {})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getgrgid(): gid not found: 2003'"
try:
ent.assert_group_by_gid(2002, dict(name="group1"))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'name' mismatch: 'group1' != 'group2'"
@@ -323,13 +323,13 @@ def test_assert_group_list(users_and_groups):
try:
ent.assert_group_list(ent.contains_only())
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert not re.search("expected groups not found:", str(e))
assert re.search("unexpected groups found:", str(e))
try:
ent.assert_group_list(ent.contains(dict(name="non_existent")))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("expected groups not found:", str(e))
assert not re.search("unexpected groups found:", str(e))
@@ -340,12 +340,12 @@ def test_assert_each_group_by_name(users_and_groups):
try:
ent.assert_each_group_by_name(dict(group3={}))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
try:
ent.assert_each_group_by_name(dict(group1=dict(name="group2")))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "group 'group1' mismatch: " + \
"'name' mismatch: 'group2' != 'group1'"
@@ -356,12 +356,12 @@ def test_assert_each_group_by_gid(users_and_groups):
try:
ent.assert_each_group_by_gid({2003:{}})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getgrgid(): gid not found: 2003'"
try:
ent.assert_each_group_by_gid({2001:dict(gid=2002)})
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"group 2001 mismatch: 'gid' mismatch: 2002 != 2001"
@@ -372,12 +372,12 @@ def test_assert_each_group_with_name(users_and_groups):
try:
ent.assert_each_group_with_name([dict(name="group3")])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
try:
ent.assert_each_group_with_name([dict(name="group1", gid=2002)])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"group 'group1' mismatch: 'gid' mismatch: 2002 != 2001"
@@ -388,12 +388,12 @@ def test_assert_each_group_with_gid(users_and_groups):
try:
ent.assert_each_group_with_gid([dict(gid=2003)])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == "'getgrgid(): gid not found: 2003'"
try:
ent.assert_each_group_with_gid([dict(name="group2", gid=2001)])
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert str(e) == \
"group 2001 mismatch: 'name' mismatch: 'group2' != 'group1'"
@@ -404,14 +404,14 @@ def test_assert_group(users_and_groups):
try:
ent.assert_group(ent.contains(dict(name="group3", gid=2003)))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("list mismatch:", str(e))
assert re.search("expected groups not found:", str(e))
assert not re.search("unexpected groups found:", str(e))
try:
ent.assert_group(ent.contains_only(GROUP1))
assert False
- except AssertionError, e:
+ except AssertionError as e:
assert re.search("list mismatch:", str(e))
assert not re.search("expected groups not found:", str(e))
assert re.search("unexpected groups found:", str(e))