PY-18816 Add tests on that annotation content can be retrieved without unstabbing

This commit is contained in:
Mikhail Golubev
2017-07-19 19:28:31 +03:00
parent b2e337f689
commit 7145542fc2
4 changed files with 39 additions and 0 deletions
@@ -0,0 +1,2 @@
def func() -> int:
pass
@@ -0,0 +1,2 @@
def func(x: int):
pass
@@ -0,0 +1 @@
x: int = ...
@@ -726,4 +726,38 @@ public class PyStubsTest extends PyTestCase {
assertNotParsed(external);
});
}
// PY-18116
public void testParameterAnnotation() {
runWithLanguageLevel(LanguageLevel.PYTHON30, () -> {
final PyFile file = getTestFile();
final PyFunction func = file.findTopLevelFunction("func");
final PyNamedParameter param = func.getParameterList().findParameterByName("x");
final String annotation = param.getAnnotationContent();
assertEquals("int", annotation);
assertNotParsed(file);
});
}
// PY-18116
public void testFunctionAnnotation() {
runWithLanguageLevel(LanguageLevel.PYTHON30, () -> {
final PyFile file = getTestFile();
final PyFunction func = file.findTopLevelFunction("func");
final String annotation = func.getAnnotationContent();
assertEquals("int", annotation);
assertNotParsed(file);
});
}
// PY-18116
public void testVariableAnnotation() {
runWithLanguageLevel(LanguageLevel.PYTHON36, () -> {
final PyFile file = getTestFile();
final PyTargetExpression var = file.findTopLevelAttribute("x");
final String annotation = var.getAnnotationContent();
assertEquals("int", annotation);
assertNotParsed(file);
});
}
}