From 4710c53dcad1ebf3755f3efb9e80ac24bd72a9b2 Mon Sep 17 00:00:00 2001
From: darylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Date: Mon, 16 Apr 2012 22:12:42 +0000
Subject: AppPkg/Applications/Python: Add Python 2.7.2 sources since the
 release of Python 2.7.3 made them unavailable from the python.org web site.

These files are a subset of the python-2.7.2.tgz distribution from python.org.  Changed files from PyMod-2.7.2 have been copied into the corresponding directories of this tree, replacing the original files in the distribution.

Signed-off-by: daryl.mcdaniel@intel.com


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13197 6f19259b-4bc3-4df7-8a09-765794883524
---
 .../Python/Python-2.7.2/Lib/test/test_copy_reg.py  | 121 +++++++++++++++++++++
 1 file changed, 121 insertions(+)
 create mode 100644 AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_copy_reg.py

(limited to 'AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_copy_reg.py')

diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_copy_reg.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_copy_reg.py
new file mode 100644
index 0000000000..1a56ac966a
--- /dev/null
+++ b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_copy_reg.py
@@ -0,0 +1,121 @@
+import copy_reg
+import unittest
+
+from test import test_support
+from test.pickletester import ExtensionSaver
+
+class C:
+    pass
+
+
+class WithoutSlots(object):
+    pass
+
+class WithWeakref(object):
+    __slots__ = ('__weakref__',)
+
+class WithPrivate(object):
+    __slots__ = ('__spam',)
+
+class WithSingleString(object):
+    __slots__ = 'spam'
+
+class WithInherited(WithSingleString):
+    __slots__ = ('eggs',)
+
+
+class CopyRegTestCase(unittest.TestCase):
+
+    def test_class(self):
+        self.assertRaises(TypeError, copy_reg.pickle,
+                          C, None, None)
+
+    def test_noncallable_reduce(self):
+        self.assertRaises(TypeError, copy_reg.pickle,
+                          type(1), "not a callable")
+
+    def test_noncallable_constructor(self):
+        self.assertRaises(TypeError, copy_reg.pickle,
+                          type(1), int, "not a callable")
+
+    def test_bool(self):
+        import copy
+        self.assertEqual(True, copy.copy(True))
+
+    def test_extension_registry(self):
+        mod, func, code = 'junk1 ', ' junk2', 0xabcd
+        e = ExtensionSaver(code)
+        try:
+            # Shouldn't be in registry now.
+            self.assertRaises(ValueError, copy_reg.remove_extension,
+                              mod, func, code)
+            copy_reg.add_extension(mod, func, code)
+            # Should be in the registry.
+            self.assertTrue(copy_reg._extension_registry[mod, func] == code)
+            self.assertTrue(copy_reg._inverted_registry[code] == (mod, func))
+            # Shouldn't be in the cache.
+            self.assertNotIn(code, copy_reg._extension_cache)
+            # Redundant registration should be OK.
+            copy_reg.add_extension(mod, func, code)  # shouldn't blow up
+            # Conflicting code.
+            self.assertRaises(ValueError, copy_reg.add_extension,
+                              mod, func, code + 1)
+            self.assertRaises(ValueError, copy_reg.remove_extension,
+                              mod, func, code + 1)
+            # Conflicting module name.
+            self.assertRaises(ValueError, copy_reg.add_extension,
+                              mod[1:], func, code )
+            self.assertRaises(ValueError, copy_reg.remove_extension,
+                              mod[1:], func, code )
+            # Conflicting function name.
+            self.assertRaises(ValueError, copy_reg.add_extension,
+                              mod, func[1:], code)
+            self.assertRaises(ValueError, copy_reg.remove_extension,
+                              mod, func[1:], code)
+            # Can't remove one that isn't registered at all.
+            if code + 1 not in copy_reg._inverted_registry:
+                self.assertRaises(ValueError, copy_reg.remove_extension,
+                                  mod[1:], func[1:], code + 1)
+
+        finally:
+            e.restore()
+
+        # Shouldn't be there anymore.
+        self.assertNotIn((mod, func), copy_reg._extension_registry)
+        # The code *may* be in copy_reg._extension_registry, though, if
+        # we happened to pick on a registered code.  So don't check for
+        # that.
+
+        # Check valid codes at the limits.
+        for code in 1, 0x7fffffff:
+            e = ExtensionSaver(code)
+            try:
+                copy_reg.add_extension(mod, func, code)
+                copy_reg.remove_extension(mod, func, code)
+            finally:
+                e.restore()
+
+        # Ensure invalid codes blow up.
+        for code in -1, 0, 0x80000000L:
+            self.assertRaises(ValueError, copy_reg.add_extension,
+                              mod, func, code)
+
+    def test_slotnames(self):
+        self.assertEqual(copy_reg._slotnames(WithoutSlots), [])
+        self.assertEqual(copy_reg._slotnames(WithWeakref), [])
+        expected = ['_WithPrivate__spam']
+        self.assertEqual(copy_reg._slotnames(WithPrivate), expected)
+        self.assertEqual(copy_reg._slotnames(WithSingleString), ['spam'])
+        expected = ['eggs', 'spam']
+        expected.sort()
+        result = copy_reg._slotnames(WithInherited)
+        result.sort()
+        self.assertEqual(result, expected)
+
+
+def test_main():
+    test_support.run_unittest(CopyRegTestCase)
+
+
+if __name__ == "__main__":
+    test_main()
-- 
cgit v1.2.3