[Python-checkins] r79045 - in python/branches/py3k: Lib/test/test_pwd.py

collin.winter python-checkins at python.org
Thu Mar 18 01:23:44 CET 2010


Author: collin.winter
Date: Thu Mar 18 01:23:44 2010
New Revision: 79045

Log:
Merged revisions 79044 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79044 | collin.winter | 2010-03-17 17:10:34 -0700 (Wed, 17 Mar 2010) | 1 line
  
  Make test_pwd more stable in the face of unusual LDAP/NIS/Kerberos deployments (the old test was flaky on Google buildslaves).
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/test/test_pwd.py

Modified: python/branches/py3k/Lib/test/test_pwd.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pwd.py	(original)
+++ python/branches/py3k/Lib/test/test_pwd.py	Thu Mar 18 01:23:44 2010
@@ -1,3 +1,4 @@
+import sys
 import unittest
 from test import support
 
@@ -83,11 +84,13 @@
 
         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.maxsize
+        self.assertNotIn(fakeuid, byuids)
         self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
 
 def test_main():


More information about the Python-checkins mailing list