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 = six.get_function_code(f1)
# unrecognized name
assert dep.extract_constant(fc, 'q', -1) is None
# constant assigned
dep.extract_constant(fc, 'x', -1) == "test"
# expression assigned
dep.extract_constant(fc, 'y', -1) == -1
# recognized name, not assigned
dep.extract_constant(fc, 'z', -1) is None
评论列表
文章目录