Python copy_reg.constructor() Examples

The following are 2 code examples of copy_reg.constructor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module copy_reg , or try the search function .
Example #1
Source File: test_copy_reg.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_constructor_neg(self):
        'https://github.com/IronLanguages/main/issues/443'
        class KOld: pass
        
        self.assertRaises(TypeError, copy_reg.constructor, KOld) 
Example #2
Source File: test_copy_reg.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_constructor(self):
        #the argument can be callable
        copy_reg.constructor(testclass)
        
        #the argument can not be callable
        self.assertRaises(TypeError,copy_reg.constructor,0)
        self.assertRaises(TypeError,copy_reg.constructor,"Hello")
        self.assertRaises(TypeError,copy_reg.constructor,True)