Skip to content

Commit

Permalink
ent_test: Update assertions for python 3.7.2
Browse files Browse the repository at this point in the history
pwd and grp modules return different string in KeyError
since python 3.7.2

  sh-4.4$ python3 --version
  Python 3.7.1
  sh-4.4$ python3 -c 'import grp; grp.getgrnam("non-exist");'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  KeyError: 'getgrnam(): name not found: non-exist'

  sh-4.4$ python3 --version
  Python 3.7.2
  sh-4.4$ python3 -c 'import grp; grp.getgrnam("non-exist");'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  KeyError: "getgrnam(): name not found: 'non-exist'"

Merges: https://pagure.io/SSSD/sssd/pull-request/3951

Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
  • Loading branch information
Lukas Slebodnik authored and jhrozek committed Feb 26, 2019
1 parent 5773463 commit 54d7175
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/tests/intg/ent_test.py
Expand Up @@ -97,7 +97,8 @@ def test_assert_passwd_by_name(users_and_groups):
ent.assert_passwd_by_name("user3", {})
assert False
except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
assert str(e) in ("'getpwnam(): name not found: user3'",
"\"getpwnam(): name not found: 'user3'\"")

try:
ent.assert_passwd_by_name("user2", dict(name="user1"))
Expand Down Expand Up @@ -150,7 +151,8 @@ def test_assert_each_passwd_by_name(users_and_groups):
ent.assert_each_passwd_by_name(dict(user3={}))
assert False
except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
assert str(e) in ("'getpwnam(): name not found: user3'",
"\"getpwnam(): name not found: 'user3'\"")
try:
ent.assert_each_passwd_by_name(dict(user1=dict(name="user2")))
assert False
Expand Down Expand Up @@ -184,7 +186,8 @@ def test_assert_each_passwd_with_name(users_and_groups):
ent.assert_each_passwd_with_name([dict(name="user3")])
assert False
except AssertionError as e:
assert str(e) == "'getpwnam(): name not found: user3'"
assert str(e) in ("'getpwnam(): name not found: user3'",
"\"getpwnam(): name not found: 'user3'\"")
try:
ent.assert_each_passwd_with_name([dict(name="user1", uid=1002)])
assert False
Expand Down Expand Up @@ -292,7 +295,8 @@ def test_assert_group_by_name(users_and_groups):
ent.assert_group_by_name("group3", {})
assert False
except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
assert str(e) in ("'getgrnam(): name not found: group3'",
"\"getgrnam(): name not found: 'group3'\"")

try:
ent.assert_group_by_name("group2", dict(name="group1"))
Expand Down Expand Up @@ -345,7 +349,8 @@ def test_assert_each_group_by_name(users_and_groups):
ent.assert_each_group_by_name(dict(group3={}))
assert False
except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
assert str(e) in ("'getgrnam(): name not found: group3'",
"\"getgrnam(): name not found: 'group3'\"")
try:
ent.assert_each_group_by_name(dict(group1=dict(name="group2")))
assert False
Expand Down Expand Up @@ -379,7 +384,8 @@ def test_assert_each_group_with_name(users_and_groups):
ent.assert_each_group_with_name([dict(name="group3")])
assert False
except AssertionError as e:
assert str(e) == "'getgrnam(): name not found: group3'"
assert str(e) in ("'getgrnam(): name not found: group3'",
"\"getgrnam(): name not found: 'group3'\"")
try:
ent.assert_each_group_with_name([dict(name="group1", gid=2002)])
assert False
Expand Down

0 comments on commit 54d7175

Please sign in to comment.