diff options
author | Collin Winter <collinw@gmail.com> | 2010-03-18 00:10:34 +0000 |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2010-03-18 00:10:34 +0000 |
commit | 43fe03a2062c8eb3b688a28cd9174a14a43eecf3 (patch) | |
tree | 917061aa958ef79d213c0f425b59651bf6ec9b91 | |
parent | d7b731d1607bcaec7f3049bd891abebbdd22fe70 (diff) | |
download | cpython-git-43fe03a2062c8eb3b688a28cd9174a14a43eecf3.tar.gz |
Make test_pwd more stable in the face of unusual LDAP/NIS/Kerberos deployments (the old test was flaky on Google buildslaves).
-rw-r--r-- | Lib/test/test_pwd.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index db42c681e3..67e11b6859 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -1,3 +1,4 @@ +import sys import unittest from test import test_support @@ -83,11 +84,13 @@ class PwdTest(unittest.TestCase): self.assertRaises(KeyError, pwd.getpwnam, fakename) - # Choose a non-existent uid. - fakeuid = 4127 - while fakeuid in byuids: - fakeuid = (fakeuid * 3) % 0x10000 - + # In some cases, byuids isn't a complete list of all users in the + # system, so if we try to pick a value not in byuids (via a perturbing + # loop, say), pwd.getpwuid() might still be able to find data for that + # uid. Using sys.maxint may provoke the same problems, but hopefully + # it will be a more repeatable failure. + fakeuid = sys.maxint + self.assertNotIn(fakeuid, byuids) self.assertRaises(KeyError, pwd.getpwuid, fakeuid) def test_main(): |