Merge branch 'origin/master'
authorElizaveta Shashkova <Elizaveta.Shashkova@jetbrains.com>
Wed, 18 Feb 2015 17:41:29 +0000 (20:41 +0300)
committerElizaveta Shashkova <Elizaveta.Shashkova@jetbrains.com>
Wed, 18 Feb 2015 17:41:29 +0000 (20:41 +0300)
1  2 
python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java

index 85b60df49184b2a357f6579b10799c5b19029924,9013d0952934dee2b42d6a20b52d204c8706b35e..5981c6b74767b36c9c182783d9db6ca0858e5f8d
@@@ -17,14 -17,9 +17,14 @@@ package com.jetbrains.python.inspection
  
  import com.intellij.codeInsight.intention.IntentionAction;
  import com.intellij.openapi.util.JDOMUtil;
 +import com.intellij.openapi.vfs.VirtualFile;
 +import com.intellij.psi.PsiElement;
 +import com.intellij.xdebugger.impl.XSourcePositionImpl;
 +import com.jetbrains.python.debugger.PyDebuggerEditorsProvider;
  import com.jetbrains.python.fixtures.PyInspectionTestCase;
  import com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection;
  import com.jetbrains.python.psi.LanguageLevel;
 +import com.jetbrains.python.psi.impl.PyExpressionCodeFragmentImpl;
  import org.jdom.Element;
  import org.jetbrains.annotations.NotNull;
  
@@@ -417,41 -412,6 +417,41 @@@ public class PyUnresolvedReferencesInsp
      myFixture.checkHighlighting(isWarning(), isInfo(), isWeakWarning());
    }
  
 +  protected VirtualFile prepareFile() {
 +    myFixture.copyDirectoryToProject(getTestDirectory(false), "");
 +    return myFixture.configureByFile(getTestDirectory(false) + "/" + getTestName(true) + ".py").getVirtualFile();
 +  }
 +
 +  protected void doEvaluateExpressionTest(@NotNull VirtualFile mainFile, @NotNull String expression, int lineNumber) {
 +    PsiElement element = PyDebuggerEditorsProvider.getContextElement(myFixture.getProject(),
 +                                                                     XSourcePositionImpl.create(mainFile, lineNumber));
 +    final PyExpressionCodeFragmentImpl fragment = new PyExpressionCodeFragmentImpl(myFixture.getProject(), "fragment.py", expression, true);
 +    fragment.setContext(element);
 +    myFixture.configureFromExistingVirtualFile(fragment.getVirtualFile());
 +    myFixture.enableInspections(getInspectionClass());
 +    myFixture.checkHighlighting(isWarning(), isInfo(), isWeakWarning());
 +  }
 +
 +  public void testEvaluateExpressionBuiltins() {
 +    VirtualFile mainFile = prepareFile();
 +    doEvaluateExpressionTest(mainFile, "len(a)", 2);
 +    doEvaluateExpressionTest(mainFile, "a", 2);
 +  }
 +
 +  public void testEvaluateExpressionInsideFunction() {
 +    VirtualFile mainFile = prepareFile();
 +    doEvaluateExpressionTest(mainFile, "a", 3);
 +    doEvaluateExpressionTest(mainFile, "s", 3);
 +  }
 +
 +  // PY-14309
 +  public void testEvaluateExpressionClass() {
 +    VirtualFile mainFile = prepareFile();
 +    doEvaluateExpressionTest(mainFile, "s", 4);
 +    doEvaluateExpressionTest(mainFile, "self", 4);
 +    doEvaluateExpressionTest(mainFile, "self.a", 4);
 +  }
 +
    // PY-13554
    public void testDocstringTypeFromSubModule() {
      doMultiFileTest();
      doTest();
    }
  
+   // PY-15002
+   public void testIncorrectFileLevelMetaclass() {
+     doTest();
+   }
    @NotNull
    @Override
    protected Class<? extends PyInspection> getInspectionClass() {