Tests to PY-286 related __doc__ resolution.

This commit is contained in:
Dmitry Cheryasov
2010-01-14 17:12:34 +02:00
parent 42498c99f6
commit 106d78f320
6 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
class Foo:
"Docstring of class Foo"
pass
Foo._<ref>_doc__

View File

@@ -0,0 +1,5 @@
def bar():
"Docstring of function bar"
retrun 1
bar._<ref>_doc__

View File

@@ -0,0 +1,8 @@
class Foo:
"Docstring of class Foo"
pass
foo = Foo()
foo._<ref>_doc__

View File

@@ -0,0 +1,5 @@
class Foo:
"This is not " + "a doc string"
pass
Foo._<ref>_.doc__

View File

@@ -0,0 +1,5 @@
"Docstring of our own module"
import DocStringModule as m
m._<ref>_doc__

View File

@@ -183,6 +183,29 @@ public class PyResolveTest extends PyResolveTestCase {
}
public void testDocStringClass() throws Exception {
PsiElement targetElement = resolve();
assertTrue(targetElement instanceof PyStringLiteralExpression);
assertEquals("Docstring of class Foo", ((PyStringLiteralExpression)targetElement).getStringValue());
}
public void testDocStringInstance() throws Exception {
PsiElement targetElement = resolve();
assertTrue(targetElement instanceof PyStringLiteralExpression);
assertEquals("Docstring of class Foo", ((PyStringLiteralExpression)targetElement).getStringValue());
}
public void testDocStringFunction() throws Exception {
PsiElement targetElement = resolve();
assertTrue(targetElement instanceof PyStringLiteralExpression);
assertEquals("Docstring of function bar", ((PyStringLiteralExpression)targetElement).getStringValue());
}
public void testDocStringInvalid() throws Exception {
PsiElement targetElement = resolve();
assertNull(targetElement);
}
@Override
protected String getTestDataPath() {
return PythonTestUtil.getTestDataPath() + "/resolve/";