summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-04-15 15:59:36 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-04-15 15:59:36 (GMT)
commit43bc1f18dbf18b9a7639f0933b829cf83d05c382 (patch)
tree073b6366404b1636351435e8c060f1e07089fc57
parent66e1e508b98f5538066a3e4196b83eb5b6904269 (diff)
downloadcpython-43bc1f18dbf18b9a7639f0933b829cf83d05c382.zip
cpython-43bc1f18dbf18b9a7639f0933b829cf83d05c382.tar.gz
cpython-43bc1f18dbf18b9a7639f0933b829cf83d05c382.tar.bz2
Fix the test so that it works even when /etc/group has two entries
for the same gid.
-rwxr-xr-xLib/test/test_grp.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 85a52c1..f27ef8c 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()
+ entriesbygid = {}
for e in entries:
self.assertEqual(len(e), 4)
@@ -22,7 +23,17 @@ class GroupDatabaseTestCase(unittest.TestCase):
self.assert_(isinstance(e.gr_mem, list))
self.assertEqual(grp.getgrnam(e.gr_name), e)
- self.assertEqual(grp.getgrgid(e.gr_gid), 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 uid
+ # and check afterwards
+ 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])
def test_errors(self):
self.assertRaises(TypeError, grp.getgrgid)