[Python-checkins] python/dist/src/Lib/test test_pwd.py,1.13,1.14
doerwalter@users.sourceforge.net
doerwalter@users.sourceforge.net
Tue, 15 Apr 2003 08:39:12 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv12357/Lib/test
Modified Files:
test_pwd.py
Log Message:
Fix the test so that it works even when /etc/passwd has two entries
for the same uid.
Index: test_pwd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pwd.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** test_pwd.py 15 Apr 2003 11:10:32 -0000 1.13
--- test_pwd.py 15 Apr 2003 15:39:08 -0000 1.14
***************
*** 8,11 ****
--- 8,12 ----
def test_values(self):
entries = pwd.getpwall()
+ entriesbyuid = {}
for e in entries:
***************
*** 27,31 ****
self.assertEqual(pwd.getpwnam(e.pw_name), e)
! self.assertEqual(pwd.getpwuid(e.pw_uid), e)
def test_errors(self):
--- 28,42 ----
self.assertEqual(pwd.getpwnam(e.pw_name), e)
! # The following won't work, because of duplicate entries
! # for one uid
! # self.assertEqual(pwd.getpwuid(e.pw_uid), e)
! # instead of this collect all entries for one uid
! # and check afterwards
! entriesbyuid.setdefault(e.pw_uid, []).append(e)
!
! # check whether the entry returned by getpwuid()
! # for each uid is among those from getpwall() for this uid
! for e in entries:
! self.assert_(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid])
def test_errors(self):