void () { final PyTargetExpression expression = assertResolvesTo(PyTargetExpression.class, PyNames.__CLASS__); final PyFunction function = PsiTreeUtil.getParentOfType(expression, PyFunction.class); assertNotNull(function); assertEquals("foo", function.getName()); }