use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.
the class PyStubsTest method testDunderAllAsSum.
public void testDunderAllAsSum() {
final PyFileImpl file = (PyFileImpl) getTestFile();
final List<String> all = file.getDunderAll();
assertSameElements(all, "md5", "sha1", "algorithms_guaranteed", "algorithms_available");
assertNotParsed(file);
}
use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.
the class PyStubsTest method testImportStatement.
public void testImportStatement() {
final PyFileImpl file = (PyFileImpl) getTestFile();
final List<PyFromImportStatement> fromImports = file.getFromImports();
assertEquals(1, fromImports.size());
final PyFromImportStatement fromImport = fromImports.get(0);
final PyImportElement[] importElements = fromImport.getImportElements();
assertEquals(1, importElements.length);
assertEquals("argv", importElements[0].getVisibleName());
assertFalse(fromImport.isStarImport());
assertEquals(0, fromImport.getRelativeLevel());
final QualifiedName qName = fromImport.getImportSourceQName();
assertSameElements(qName.getComponents(), "sys");
final List<PyImportElement> importTargets = file.getImportTargets();
assertEquals(1, importTargets.size());
final PyImportElement importElement = importTargets.get(0);
final QualifiedName importQName = importElement.getImportedQName();
assertSameElements(importQName.getComponents(), "os", "path");
assertNotParsed(file);
}
use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.
the class PyStubsTest method testDunderAll.
public void testDunderAll() {
final PyFileImpl file = (PyFileImpl) getTestFile();
final List<String> all = file.getDunderAll();
assertSameElements(all, "foo", "bar");
assertNotParsed(file);
}
use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.
the class PyStubsTest method testIfNameMain.
public void testIfNameMain() {
// PY-4008
final PyFileImpl file = (PyFileImpl) getTestFile();
ensureVariableNotInIndex("xyzzy");
assertNotParsed(file);
// assert no error on switching from stub to AST
file.acceptChildren(new PyRecursiveElementVisitor());
assertNotNull(file.getTreeElement());
}
use of com.jetbrains.python.psi.impl.PyFileImpl in project intellij-community by JetBrains.
the class PyStubsTest method testImportInExcept.
public void testImportInExcept() {
final PyFileImpl file = (PyFileImpl) getTestFile();
final PsiElement element = file.getElementNamed("tzinfo");
assertTrue(element != null ? element.toString() : "null", element instanceof PyClass);
assertNotParsed(file);
}
Aggregations