def test_scope(self):
        
        def func(self):
            def foo(z):
                y = 2
                stub = False  # noqa
                only_here = 1  # noqa
                return x + y + z
            x = 1
            y = 0
            y = 1  # noqa
            z = 1  # noqa
            res = foo(3)
            stub = True  # noqa
            return res + y  # should return 1+2+3+1 == 7
        
        # Find function start
        code = py2js(func)
        i = code.splitlines().index('var func;')
        assert i >= 0
        
        # Find first lines of functions, where the vars are defined
        vars1 = code.splitlines()[i+2]
        vars2 = code.splitlines()[i+4]
        assert vars1.strip().startswith('var ')
        assert vars2.strip().startswith('var ')
        
        assert 'y' in vars1 and 'y' in vars2
        assert 'stub' in vars1 and 'stub' in vars2
        assert 'only_here' in vars2 and 'only_here' not in vars1
        assert evaljs(code + 'func()') == '7'
dataset/ETHPy150Open zoofIO/flexx/flexx/pyscript/tests/test_parser2.py/TestFunctions.test_scope/original