Merge remote-tracking branch 'origin/master' into mikhail.golubev/py-attribute-inference
[idea/community.git] / python / testSrc / com / jetbrains / python / PythonCompletionTest.java
index 1d7181fa9a1bb964449f6cd4aba5379daee91c44..fe379fea37baca4f3978415a3e909891f429147b 100644 (file)
@@ -514,18 +514,16 @@ public class PythonCompletionTest extends PyTestCase {
   }
 
   public void testRelativeImportExcludeToplevel() {  // PY-6304
-    setLanguageLevel(LanguageLevel.PYTHON27);
-    try {
-      myFixture.copyDirectoryToProject("completion/relativeImportExcludeToplevel", "");
-      myFixture.configureByFile("pack/subpack/modX.py");
-      myFixture.completeBasic();
-      final List<String> lookupElementStrings = myFixture.getLookupElementStrings();
-      assertNotNull(lookupElementStrings);
-      assertFalse(lookupElementStrings.contains("sys"));
-    }
-    finally {
-      setLanguageLevel(null);
-    }
+    runWithLanguageLevel(LanguageLevel.PYTHON27, new Runnable() {
+      @Override
+      public void run() {
+        myFixture.copyDirectoryToProject("completion/relativeImportExcludeToplevel", "");
+        myFixture.configureByFile("pack/subpack/modX.py");
+        myFixture.completeBasic();
+        assertNull(myFixture.getLookupElementStrings());
+        myFixture.checkResult("from ...subpack import");
+      }
+    });
   }
 
   // PY-2813