'test the location of identifiers in a python code string'

def test_locate_identifiers(self):

    code = '\na    =    10\nb    =    5\nc    =    x    *    5    +    a    +    b    +    q\n(g,h,i)    =    (1,2,3)\n[u,k,j]    =    [4,5,6]\nfoo.hoho.lala.bar    =    7    +    gah.blah    +    u    +    blah\nfor    lar    in    (1,2,3):\n                gh    =    5\n                x    =    12\n("hello    world,    ",    a,    b)\n("Another    expr",    c)\n'
    parsed = ast.PythonCode(code, **exception_kwargs)
    eq_(parsed.declared_identifiers, set(['a', 'b', 'c', 'g', 'h', 'i', 'u', 'k', 'j', 'gh', 'lar', 'x']))
    eq_(parsed.undeclared_identifiers, set(['x', 'q', 'foo', 'gah', 'blah']))
    parsed = ast.PythonCode('x    +    5    *    (y-z)', **exception_kwargs)
    assert (parsed.undeclared_identifiers == set(['x', 'y', 'z']))
    assert (parsed.declared_identifiers == set())
