Added runWithLanguageLevel() for Python testes

This commit is contained in:
Andrey Vlasovskikh
2012-08-30 16:15:13 +04:00
parent e392e3ba56
commit 5e314dbb48
@@ -27,6 +27,7 @@ import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.psi.PyFile;
import com.jetbrains.python.psi.impl.PyFileImpl;
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -89,6 +90,16 @@ public abstract class PyTestCase extends UsefulTestCase {
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), languageLevel);
}
protected void runWithLanguageLevel(@NotNull LanguageLevel languageLevel, @NotNull Runnable action) {
setLanguageLevel(languageLevel);
try {
action.run();
}
finally {
setLanguageLevel(null);
}
}
protected static void assertNotParsed(PyFile file) {
assertNull(PARSED_ERROR_MSG, ((PyFileImpl)file).getTreeElement());
}