diff options
author | Walter Dörwald <walter@livinglogic.de> | 2003-04-15 15:39:08 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2003-04-15 15:39:08 (GMT) |
commit | 66e1e508b98f5538066a3e4196b83eb5b6904269 (patch) | |
tree | d2e466808dab4f7f4a7346101c9f0631e3530e0e /Lib/test/test_pwd.py | |
parent | 0fc8f00252d305a3a45ee8cf924e0b5d6be4472b (diff) | |
download | cpython-66e1e508b98f5538066a3e4196b83eb5b6904269.zip cpython-66e1e508b98f5538066a3e4196b83eb5b6904269.tar.gz cpython-66e1e508b98f5538066a3e4196b83eb5b6904269.tar.bz2 |
Fix the test so that it works even when /etc/passwd has two entries
for the same uid.
Diffstat (limited to 'Lib/test/test_pwd.py')
-rw-r--r-- | Lib/test/test_pwd.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index 78f9a69..6cc52d7 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -7,6 +7,7 @@ class PwdTest(unittest.TestCase): def test_values(self): entries = pwd.getpwall() + entriesbyuid = {} for e in entries: self.assertEqual(len(e), 7) @@ -26,7 +27,17 @@ class PwdTest(unittest.TestCase): self.assert_(isinstance(e.pw_shell, basestring)) self.assertEqual(pwd.getpwnam(e.pw_name), e) - self.assertEqual(pwd.getpwuid(e.pw_uid), 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): self.assertRaises(TypeError, pwd.getpwuid) |