summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pwd.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_pwd.py')
-rw-r--r--Lib/test/test_pwd.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index c13a7c9..828f6de 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -1,10 +1,9 @@
import sys
import unittest
-from test import support
+from test import test_support
-pwd = support.import_module('pwd')
+pwd = test_support.import_module('pwd')
-@unittest.skipUnless(hasattr(pwd, 'getpwall'), 'Does not have getpwall()')
class PwdTest(unittest.TestCase):
def test_values(self):
@@ -13,19 +12,19 @@ class PwdTest(unittest.TestCase):
for e in entries:
self.assertEqual(len(e), 7)
self.assertEqual(e[0], e.pw_name)
- self.assertIsInstance(e.pw_name, str)
+ self.assertIsInstance(e.pw_name, basestring)
self.assertEqual(e[1], e.pw_passwd)
- self.assertIsInstance(e.pw_passwd, str)
+ self.assertIsInstance(e.pw_passwd, basestring)
self.assertEqual(e[2], e.pw_uid)
- self.assertIsInstance(e.pw_uid, int)
+ self.assertIsInstance(e.pw_uid, (int, long))
self.assertEqual(e[3], e.pw_gid)
- self.assertIsInstance(e.pw_gid, int)
+ self.assertIsInstance(e.pw_gid, (int, long))
self.assertEqual(e[4], e.pw_gecos)
- self.assertIsInstance(e.pw_gecos, str)
+ self.assertIsInstance(e.pw_gecos, basestring)
self.assertEqual(e[5], e.pw_dir)
- self.assertIsInstance(e.pw_dir, str)
+ self.assertIsInstance(e.pw_dir, basestring)
self.assertEqual(e[6], e.pw_shell)
- self.assertIsInstance(e.pw_shell, str)
+ self.assertIsInstance(e.pw_shell, basestring)
# The following won't work, because of duplicate entries
# for one uid
@@ -67,12 +66,12 @@ class PwdTest(unittest.TestCase):
bynames[n] = u
byuids[u] = n
- allnames = list(bynames.keys())
+ allnames = bynames.keys()
namei = 0
fakename = allnames[namei]
while fakename in bynames:
chars = list(fakename)
- for i in range(len(chars)):
+ for i in xrange(len(chars)):
if chars[i] == 'z':
chars[i] = 'A'
break
@@ -97,7 +96,7 @@ class PwdTest(unittest.TestCase):
# 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
+ fakeuid = sys.maxint
self.assertNotIn(fakeuid, byuids)
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
@@ -108,5 +107,8 @@ class PwdTest(unittest.TestCase):
self.assertRaises(KeyError, pwd.getpwuid, 2**128)
self.assertRaises(KeyError, pwd.getpwuid, -2**128)
+def test_main():
+ test_support.run_unittest(PwdTest)
+
if __name__ == "__main__":
- unittest.main()
+ test_main()