Back to index

python3.2  3.2.2
Public Member Functions
test.test_copyreg.CopyRegTestCase Class Reference

List of all members.

Public Member Functions

def test_class
def test_noncallable_reduce
def test_noncallable_constructor
def test_bool
def test_extension_registry
def test_slotnames

Detailed Description

Definition at line 27 of file test_copyreg.py.


Member Function Documentation

Definition at line 41 of file test_copyreg.py.

00041 
00042     def test_bool(self):
00043         import copy
00044         self.assertEqual(True, copy.copy(True))

Here is the call graph for this function:

Definition at line 29 of file test_copyreg.py.

00029 
00030     def test_class(self):
00031         self.assertRaises(TypeError, copyreg.pickle,
00032                           C, None, None)

Here is the call graph for this function:

Definition at line 45 of file test_copyreg.py.

00045 
00046     def test_extension_registry(self):
00047         mod, func, code = 'junk1 ', ' junk2', 0xabcd
00048         e = ExtensionSaver(code)
00049         try:
00050             # Shouldn't be in registry now.
00051             self.assertRaises(ValueError, copyreg.remove_extension,
00052                               mod, func, code)
00053             copyreg.add_extension(mod, func, code)
00054             # Should be in the registry.
00055             self.assertTrue(copyreg._extension_registry[mod, func] == code)
00056             self.assertTrue(copyreg._inverted_registry[code] == (mod, func))
00057             # Shouldn't be in the cache.
00058             self.assertNotIn(code, copyreg._extension_cache)
00059             # Redundant registration should be OK.
00060             copyreg.add_extension(mod, func, code)  # shouldn't blow up
00061             # Conflicting code.
00062             self.assertRaises(ValueError, copyreg.add_extension,
00063                               mod, func, code + 1)
00064             self.assertRaises(ValueError, copyreg.remove_extension,
00065                               mod, func, code + 1)
00066             # Conflicting module name.
00067             self.assertRaises(ValueError, copyreg.add_extension,
00068                               mod[1:], func, code )
00069             self.assertRaises(ValueError, copyreg.remove_extension,
00070                               mod[1:], func, code )
00071             # Conflicting function name.
00072             self.assertRaises(ValueError, copyreg.add_extension,
00073                               mod, func[1:], code)
00074             self.assertRaises(ValueError, copyreg.remove_extension,
00075                               mod, func[1:], code)
00076             # Can't remove one that isn't registered at all.
00077             if code + 1 not in copyreg._inverted_registry:
00078                 self.assertRaises(ValueError, copyreg.remove_extension,
00079                                   mod[1:], func[1:], code + 1)
00080 
00081         finally:
00082             e.restore()
00083 
00084         # Shouldn't be there anymore.
00085         self.assertNotIn((mod, func), copyreg._extension_registry)
00086         # The code *may* be in copyreg._extension_registry, though, if
00087         # we happened to pick on a registered code.  So don't check for
00088         # that.
00089 
00090         # Check valid codes at the limits.
00091         for code in 1, 0x7fffffff:
00092             e = ExtensionSaver(code)
00093             try:
00094                 copyreg.add_extension(mod, func, code)
00095                 copyreg.remove_extension(mod, func, code)
00096             finally:
00097                 e.restore()
00098 
00099         # Ensure invalid codes blow up.
00100         for code in -1, 0, 0x80000000:
00101             self.assertRaises(ValueError, copyreg.add_extension,
00102                               mod, func, code)

Here is the call graph for this function:

Definition at line 37 of file test_copyreg.py.

00037 
00038     def test_noncallable_constructor(self):
00039         self.assertRaises(TypeError, copyreg.pickle,
00040                           type(1), int, "not a callable")

Here is the call graph for this function:

Definition at line 33 of file test_copyreg.py.

00033 
00034     def test_noncallable_reduce(self):
00035         self.assertRaises(TypeError, copyreg.pickle,
00036                           type(1), "not a callable")

Here is the call graph for this function:

Definition at line 103 of file test_copyreg.py.

00103 
00104     def test_slotnames(self):
00105         self.assertEqual(copyreg._slotnames(WithoutSlots), [])
00106         self.assertEqual(copyreg._slotnames(WithWeakref), [])
00107         expected = ['_WithPrivate__spam']
00108         self.assertEqual(copyreg._slotnames(WithPrivate), expected)
00109         self.assertEqual(copyreg._slotnames(WithSingleString), ['spam'])
00110         expected = ['eggs', 'spam']
00111         expected.sort()
00112         result = copyreg._slotnames(WithInherited)
00113         result.sort()
00114         self.assertEqual(result, expected)
00115 

Here is the call graph for this function:


The documentation for this class was generated from the following file: