Kaydet (Commit) 43fe03a2 authored tarafından Collin Winter's avatar Collin Winter

Make test_pwd more stable in the face of unusual LDAP/NIS/Kerberos deployments…

Make test_pwd more stable in the face of unusual LDAP/NIS/Kerberos deployments (the old test was flaky on Google buildslaves).
üst d7b731d1
import sys
import unittest import unittest
from test import test_support from test import test_support
...@@ -83,11 +84,13 @@ class PwdTest(unittest.TestCase): ...@@ -83,11 +84,13 @@ class PwdTest(unittest.TestCase):
self.assertRaises(KeyError, pwd.getpwnam, fakename) self.assertRaises(KeyError, pwd.getpwnam, fakename)
# Choose a non-existent uid. # In some cases, byuids isn't a complete list of all users in the
fakeuid = 4127 # system, so if we try to pick a value not in byuids (via a perturbing
while fakeuid in byuids: # loop, say), pwd.getpwuid() might still be able to find data for that
fakeuid = (fakeuid * 3) % 0x10000 # 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) self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
def test_main(): def test_main():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment