def testExtractConst(self): if not hasattr(dep, 'extract_constant'): # skip on non-bytecode platforms return def f1(): global x, y, z x = "test" y = z fc = func_code(f1) # unrecognized name self.assertEqual(dep.extract_constant(fc, 'q', -1), None) # constant assigned self.assertEqual(dep.extract_constant(fc, 'x', -1), "test") # expression assigned self.assertEqual(dep.extract_constant(fc, 'y', -1), -1) # recognized name, not assigned self.assertEqual(dep.extract_constant(fc, 'z', -1), None)
def testExtractConst(self): if not hasattr(dep, 'extract_constant'): # skip on non-bytecode platforms return def f1(): global x, y, z x = "test" y = z fc = func_code(f1) # unrecognized name self.assertEqual(dep.extract_constant(fc,'q', -1), None) # constant assigned self.assertEqual(dep.extract_constant(fc,'x', -1), "test") # expression assigned self.assertEqual(dep.extract_constant(fc,'y', -1), -1) # recognized name, not assigned self.assertEqual(dep.extract_constant(fc,'z', -1), None)