use of com.jetbrains.python.psi.types.PyType in project intellij-community by JetBrains.
the class Py3TypeTest method assertType.
private static void assertType(String expectedType, PyExpression expr, TypeEvalContext context) {
final PyType actual = context.getType(expr);
final String actualType = PythonDocumentationProvider.getTypeName(actual, context);
assertEquals(expectedType, actualType);
}
use of com.jetbrains.python.psi.types.PyType in project intellij-community by JetBrains.
the class PyClassicPropertyTest method testV3.
public void testV3() throws Exception {
Maybe<PyCallable> accessor;
Property p = myClass.findProperty("v3", true, null);
assertNotNull(p);
assertNull(p.getDoc());
PyTargetExpression site = p.getDefinitionSite();
assertEquals("v3", site.getText());
accessor = p.getGetter();
assertFalse(accessor.isDefined());
final PyType codeInsightType = p.getType(null, TypeEvalContext.codeInsightFallback(myClass.getProject()));
assertNull(codeInsightType);
accessor = p.getSetter();
assertTrue(accessor.isDefined());
assertNull(accessor.value());
accessor = p.getDeleter();
assertTrue(accessor.isDefined());
assertNotNull(accessor.value());
assertEquals("deleter", accessor.value().getName());
}
use of com.jetbrains.python.psi.types.PyType in project intellij-community by JetBrains.
the class PyTypeTest method checkTypes.
private static void checkTypes(@NotNull String expectedType, @Nullable PyExpression expr) {
assertNotNull(expr);
for (TypeEvalContext context : getTypeEvalContexts(expr)) {
final PyType actual = context.getType(expr);
final String actualType = PythonDocumentationProvider.getTypeName(actual, context);
assertEquals("Failed in " + context, expectedType, actualType);
}
}
use of com.jetbrains.python.psi.types.PyType in project intellij-community by JetBrains.
the class PyTypingTest method assertType.
private static void assertType(String expectedType, PyExpression expr, TypeEvalContext context, String contextName) {
final PyType actual = context.getType(expr);
final String actualType = PythonDocumentationProvider.getTypeName(actual, context);
assertEquals("Failed in " + contextName + " context", expectedType, actualType);
}
use of com.jetbrains.python.psi.types.PyType in project intellij-community by JetBrains.
the class PyStubsTest method doTestUnsupportedNamedTuple.
private void doTestUnsupportedNamedTuple() {
final PyFile file = getTestFile();
final PyTargetExpression attribute = file.findTopLevelAttribute("nt");
assertNotNull(attribute);
final PyType typeFromStub = TypeEvalContext.codeInsightFallback(myFixture.getProject()).getType(attribute);
assertNull(typeFromStub);
assertNotParsed(file);
final FileASTNode astNode = file.getNode();
assertNotNull(astNode);
final PyType typeFromAst = TypeEvalContext.userInitiated(myFixture.getProject(), file).getType(attribute);
assertNull(typeFromAst);
}
Aggregations