summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pwd.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_pwd.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_pwd.py')
-rw-r--r--Lib/test/test_pwd.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index 6cc52d7..dbdea79 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()
+ entriesbyname = {}
entriesbyuid = {}
for e in entries:
@@ -26,17 +27,18 @@ class PwdTest(unittest.TestCase):
self.assertEqual(e[6], e.pw_shell)
self.assert_(isinstance(e.pw_shell, basestring))
- 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
+ entriesbyname.setdefault(e.pw_name, []).append(e)
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.getpwnam(e.pw_name) in entriesbyname[e.pw_name])
self.assert_(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid])
def test_errors(self):