예제 #1
0
    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)
예제 #2
0
파일: __init__.py 프로젝트: 0x/kivi-tests
    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)