[Python-checkins] python/dist/src/Lib/test test_grp.py,1.11,1.12

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Tue, 15 Apr 2003 08:59:40 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv22898/Lib/test

Modified Files:
	test_grp.py 
Log Message:
Fix the test so that it works even when /etc/group has two entries
for the same gid.


Index: test_grp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grp.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_grp.py	15 Apr 2003 11:10:33 -0000	1.11
--- test_grp.py	15 Apr 2003 15:59:36 -0000	1.12
***************
*** 10,13 ****
--- 10,14 ----
      def test_values(self):
          entries = grp.getgrall()
+         entriesbygid = {}
  
          for e in entries:
***************
*** 23,27 ****
  
              self.assertEqual(grp.getgrnam(e.gr_name), e)
!             self.assertEqual(grp.getgrgid(e.gr_gid), e)
  
      def test_errors(self):
--- 24,38 ----
  
              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 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):