def test_func_automatic_naming(profiler_cls):
    """Test that decorated region name is correctly
    deduced from the code location.
    """
    rp = profiler_cls()

    @rp.func()
    def foo():
        with rp.region('inner'):
            return 42

    @rp.func()
    def baz():
        return foo() + foo()

    x = baz() + foo()
    ch = rp.root.children
    assert set(ch.keys()) == {'foo()', 'baz()'}
    assert set(ch['foo()'].children.keys()) == {'inner'}
    assert set(ch['baz()'].children.keys()) == {'foo()'}
    assert set(ch['baz()'].children['foo()'].children.keys()) == {'inner'}