PY-29717 Add missing tests on parameter formatting

This commit is contained in:
Mikhail Golubev
2018-06-01 19:45:52 +03:00
parent 67ebed5232
commit b65b315dae
11 changed files with 48 additions and 5 deletions

View File

@@ -190,7 +190,7 @@ public class PyDocumentationBuilder {
private void buildFromParameter(@NotNull PyNamedParameter parameter) {
final PyFunction func = PsiTreeUtil.getParentOfType(parameter, PyFunction.class, true, PyLambdaExpression.class);
final String link = func != null ? getLinkToFunction(func, true) : PyNames.UNNAMED_ELEMENT;
final String link = func != null ? getLinkToFunction(func, true) : StringUtil.escapeXml(PyNames.UNNAMED_ELEMENT);
if (link != null) {
myProlog
.addItem("Parameter ")

View File

@@ -0,0 +1 @@
<html><body><div class='definition'><pre>Parameter <b>param</b> of func<br>param: Any</pre></div></body></html>

View File

@@ -0,0 +1,2 @@
def func(par<the_ref>am):
pass

View File

@@ -0,0 +1,2 @@
def func(par<the_ref>am):
pass

View File

@@ -0,0 +1 @@
<html><body><div class='definition'><pre>Parameter <b>param</b> of MyClass.method<br>param: Any</pre></div></body></html>

View File

@@ -0,0 +1,4 @@
def hidden():
class MyClass:
def method(self, pa<the_ref>ram):
pass

View File

@@ -0,0 +1 @@
<html><body><div class='definition'><pre>Parameter <b>param</b> of func<br>param: Any</pre></div></body></html>

View File

@@ -0,0 +1,3 @@
def hidden():
def func(par<the_ref>am):
pass

View File

@@ -0,0 +1 @@
<html><body><div class='definition'><pre>Parameter <b>param</b> of &lt;unnamed&gt;<br>param: Any</pre></div></body></html>

View File

@@ -0,0 +1 @@
func = lambda pa<the_ref>ram: 42

View File

@@ -1,7 +1,6 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python;
import com.intellij.codeInsight.TargetElementUtil;
import com.intellij.codeInsight.documentation.DocumentationManager;
import com.intellij.psi.PsiElement;
import com.jetbrains.python.documentation.PyDocumentationSettings;
@@ -38,12 +37,12 @@ public class PyQuickDocTest extends LightMarkedTestCase {
}
private void checkByHTML(@NotNull String text) {
assertSameLinesWithFile(getTestDataPath() + "/quickdoc/" + getTestName(false) + ".html", text);
assertSameLinesWithFile(getTestDataPath() + getTestName(false) + ".html", text);
}
@Override
protected Map<String, PsiElement> loadTest() {
return configureByFile("/quickdoc/" + getTestName(false) + ".py");
return configureByFile(getTestName(false) + ".py");
}
private void checkRefDocPair() {
@@ -215,6 +214,29 @@ public class PyQuickDocTest extends LightMarkedTestCase {
checkHTMLOnly();
}
public void testParamOfInnerFunction() {
checkHTMLOnly();
}
public void testParamOfInnerClassMethod() {
checkHTMLOnly();
}
public void testParamOfFunctionInModuleWithIllegalName() {
final Map<String, PsiElement> marks = configureByFile(getTestName(false) + "/illegal name.py");
final PsiElement originalElement = marks.get("<the_ref>");
final DocumentationManager manager = DocumentationManager.getInstance(myFixture.getProject());
final PsiElement target = manager.findTargetElement(myFixture.getEditor(),
originalElement.getTextOffset(),
myFixture.getFile(),
originalElement);
checkByHTML(myProvider.generateDoc(target, originalElement));
}
public void testParamOfLambda() {
checkHTMLOnly();
}
public void testInstanceAttr() {
checkHTMLOnly();
}
@@ -251,7 +273,7 @@ public class PyQuickDocTest extends LightMarkedTestCase {
// PY-13422
public void testNumPyOnesDoc() {
myFixture.copyDirectoryToProject("/quickdoc/" + getTestName(false), "");
myFixture.copyDirectoryToProject(getTestName(false), "");
checkHover();
}
@@ -418,4 +440,9 @@ public class PyQuickDocTest extends LightMarkedTestCase {
public void testSingleLineAssignedValueForTarget() {
checkHTMLOnly();
}
@Override
protected String getTestDataPath() {
return super.getTestDataPath() + "/quickdoc/";
}
}