summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grp.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-04-22 11:05:57 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-04-22 11:05:57 (GMT)
commitecd2fdca0f9461b149ca6d0bcf070deac5e7ca9a (patch)
tree79ff9383e9bbe3f51d32edfd7602ff8797c5acea /Lib/test/test_grp.py
parent41c9f880d8bf59e80b6ca5963c3e9e2b17386736 (diff)
downloadcpython-ecd2fdca0f9461b149ca6d0bcf070deac5e7ca9a.zip
cpython-ecd2fdca0f9461b149ca6d0bcf070deac5e7ca9a.tar.gz
cpython-ecd2fdca0f9461b149ca6d0bcf070deac5e7ca9a.tar.bz2
Change test_pwd and test_grp so they can handle duplicate user
and group names. This should fix SF bug #724771.
Diffstat (limited to 'Lib/test/test_grp.py')
-rwxr-xr-xLib/test/test_grp.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 71c4897..76323a2 100755
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -9,6 +9,7 @@ class GroupDatabaseTestCase(unittest.TestCase):
def test_values(self):
entries = grp.getgrall()
+ entriesbyname = {}
entriesbygid = {}
for e in entries:
@@ -22,18 +23,19 @@ class GroupDatabaseTestCase(unittest.TestCase):
self.assertEqual(e[3], e.gr_mem)
self.assert_(isinstance(e.gr_mem, list))
- self.assertEqual(grp.getgrnam(e.gr_name), e)
# The following won't work, because of duplicate entries
# for one gid
# self.assertEqual(grp.getgrgid(e.gr_gid), e)
- # instead of this collect all entries for one gid
+ # instead of this collect all entries for one gid/name
# and check afterwards
+ entriesbyname.setdefault(e.gr_name, []).append(e)
entriesbygid.setdefault(e.gr_gid, []).append(e)
# check whether the entry returned by getgrgid()
# for each uid is among those from getgrall() for this uid
for e in entries:
self.assert_(grp.getgrgid(e.gr_gid) in entriesbygid[e.gr_gid])
+ self.assert_(grp.getgrnam(e.gr_name) in entriesbyname[e.gr_name])
def test_errors(self):
self.assertRaises(TypeError, grp.getgrgid)