]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_pwd.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_pwd.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_pwd.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_pwd.py
deleted file mode 100644 (file)
index 435a130..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-import sys\r
-import unittest\r
-from test import test_support\r
-\r
-pwd = test_support.import_module('pwd')\r
-\r
-class PwdTest(unittest.TestCase):\r
-\r
-    def test_values(self):\r
-        entries = pwd.getpwall()\r
-        entriesbyname = {}\r
-        entriesbyuid = {}\r
-\r
-        for e in entries:\r
-            self.assertEqual(len(e), 7)\r
-            self.assertEqual(e[0], e.pw_name)\r
-            self.assertIsInstance(e.pw_name, basestring)\r
-            self.assertEqual(e[1], e.pw_passwd)\r
-            self.assertIsInstance(e.pw_passwd, basestring)\r
-            self.assertEqual(e[2], e.pw_uid)\r
-            self.assertIsInstance(e.pw_uid, int)\r
-            self.assertEqual(e[3], e.pw_gid)\r
-            self.assertIsInstance(e.pw_gid, int)\r
-            self.assertEqual(e[4], e.pw_gecos)\r
-            self.assertIsInstance(e.pw_gecos, basestring)\r
-            self.assertEqual(e[5], e.pw_dir)\r
-            self.assertIsInstance(e.pw_dir, basestring)\r
-            self.assertEqual(e[6], e.pw_shell)\r
-            self.assertIsInstance(e.pw_shell, basestring)\r
-\r
-            # The following won't work, because of duplicate entries\r
-            # for one uid\r
-            #    self.assertEqual(pwd.getpwuid(e.pw_uid), e)\r
-            # instead of this collect all entries for one uid\r
-            # and check afterwards\r
-            entriesbyname.setdefault(e.pw_name, []).append(e)\r
-            entriesbyuid.setdefault(e.pw_uid, []).append(e)\r
-\r
-        if len(entries) > 1000:  # Huge passwd file (NIS?) -- skip the rest\r
-            return\r
-\r
-        # check whether the entry returned by getpwuid()\r
-        # for each uid is among those from getpwall() for this uid\r
-        for e in entries:\r
-            if not e[0] or e[0] == '+':\r
-                continue # skip NIS entries etc.\r
-            self.assertIn(pwd.getpwnam(e.pw_name), entriesbyname[e.pw_name])\r
-            self.assertIn(pwd.getpwuid(e.pw_uid), entriesbyuid[e.pw_uid])\r
-\r
-    def test_errors(self):\r
-        self.assertRaises(TypeError, pwd.getpwuid)\r
-        self.assertRaises(TypeError, pwd.getpwnam)\r
-        self.assertRaises(TypeError, pwd.getpwall, 42)\r
-\r
-        # try to get some errors\r
-        bynames = {}\r
-        byuids = {}\r
-        for (n, p, u, g, gecos, d, s) in pwd.getpwall():\r
-            bynames[n] = u\r
-            byuids[u] = n\r
-\r
-        allnames = bynames.keys()\r
-        namei = 0\r
-        fakename = allnames[namei]\r
-        while fakename in bynames:\r
-            chars = list(fakename)\r
-            for i in xrange(len(chars)):\r
-                if chars[i] == 'z':\r
-                    chars[i] = 'A'\r
-                    break\r
-                elif chars[i] == 'Z':\r
-                    continue\r
-                else:\r
-                    chars[i] = chr(ord(chars[i]) + 1)\r
-                    break\r
-            else:\r
-                namei = namei + 1\r
-                try:\r
-                    fakename = allnames[namei]\r
-                except IndexError:\r
-                    # should never happen... if so, just forget it\r
-                    break\r
-            fakename = ''.join(chars)\r
-\r
-        self.assertRaises(KeyError, pwd.getpwnam, fakename)\r
-\r
-        # In some cases, byuids isn't a complete list of all users in the\r
-        # system, so if we try to pick a value not in byuids (via a perturbing\r
-        # loop, say), pwd.getpwuid() might still be able to find data for that\r
-        # uid. Using sys.maxint may provoke the same problems, but hopefully\r
-        # it will be a more repeatable failure.\r
-        fakeuid = sys.maxint\r
-        self.assertNotIn(fakeuid, byuids)\r
-        self.assertRaises(KeyError, pwd.getpwuid, fakeuid)\r
-\r
-def test_main():\r
-    test_support.run_unittest(PwdTest)\r
-\r
-if __name__ == "__main__":\r
-    test_main()\r