Python copyreg.constructor() Examples

The following are 2 code examples of copyreg.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 copyreg , or try the search function .
Example #1
Source File: test_copyreg.py    From ironpython3 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, copyreg.constructor, KOld) 
Example #2
Source File: test_copyreg.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_constructor(self):
        #the argument can be callable
        copyreg.constructor(testclass)
        
        #the argument can not be callable
        self.assertRaises(TypeError,copyreg.constructor,0)
        self.assertRaises(TypeError,copyreg.constructor,"Hello")
        self.assertRaises(TypeError,copyreg.constructor,True)