mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-9795 Add several tests of references in Google Code Style docstrings
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
class C:
|
||||
"""
|
||||
Attributes:
|
||||
foo : ignored
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.fo<caret>o = 42
|
||||
@@ -0,0 +1,8 @@
|
||||
class C:
|
||||
"""
|
||||
Attributes:
|
||||
bar : ignored
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.bar = 42
|
||||
@@ -0,0 +1,6 @@
|
||||
def func(fo<caret>o):
|
||||
"""
|
||||
Parameters:
|
||||
foo : ignored
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
class F<caret>oo: pass
|
||||
|
||||
def func(foo):
|
||||
"""
|
||||
Parameters:
|
||||
foo (Foo): ignored
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar: pass
|
||||
|
||||
def func(foo):
|
||||
"""
|
||||
Parameters:
|
||||
foo (Bar): ignored
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,6 @@
|
||||
def func(bar):
|
||||
"""
|
||||
Parameters:
|
||||
bar : ignored
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
class F<caret>oo: pass
|
||||
|
||||
def func(foo):
|
||||
"""
|
||||
Returns:
|
||||
Foo: ignored
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar: pass
|
||||
|
||||
def func(foo):
|
||||
"""
|
||||
Returns:
|
||||
Bar: ignored
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
from datetime import datetime
|
||||
|
||||
def f(param):
|
||||
"""
|
||||
Parameters:
|
||||
param (datetime) : timestamp
|
||||
<ref>
|
||||
"""
|
||||
@@ -0,0 +1,10 @@
|
||||
class MyClass:
|
||||
pass
|
||||
|
||||
|
||||
def f(param):
|
||||
"""
|
||||
Returns:
|
||||
MyClass : new instance of MyClass
|
||||
<ref>
|
||||
"""
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
|
||||
import com.jetbrains.python.documentation.DocStringFormat;
|
||||
import com.jetbrains.python.fixtures.PyResolveTestCase;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
@@ -508,6 +509,24 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
public void testReferenceInDocstring() {
|
||||
assertResolvesTo(PyClass.class, "datetime");
|
||||
}
|
||||
|
||||
// PY-9795
|
||||
public void testGoogleDocstringParamType() {
|
||||
runWithDocStringFormat(DocStringFormat.GOOGLE, new Runnable() {
|
||||
public void run() {
|
||||
assertResolvesTo(PyClass.class, "datetime");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-9795
|
||||
public void testGoogleDocstringReturnType() {
|
||||
runWithDocStringFormat(DocStringFormat.GOOGLE, new Runnable() {
|
||||
public void run() {
|
||||
assertResolvesTo(PyClass.class, "MyClass");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-7541
|
||||
public void testLoopToUpperReassignment() {
|
||||
|
||||
@@ -61,6 +61,8 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import com.jetbrains.python.documentation.DocStringFormat;
|
||||
import com.jetbrains.python.documentation.PyDocumentationSettings;
|
||||
import com.jetbrains.python.formatter.PyCodeStyleSettings;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
@@ -185,6 +187,18 @@ public abstract class PyTestCase extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void runWithDocStringFormat(@NotNull DocStringFormat format, @NotNull Runnable runnable) {
|
||||
final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
|
||||
final DocStringFormat oldFormat = settings.getFormat();
|
||||
settings.setFormat(format);
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
finally {
|
||||
settings.setFormat(oldFormat);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for quickfix itetion by its class
|
||||
*
|
||||
|
||||
@@ -603,20 +603,8 @@ public class PyIntentionTest extends PyTestCase {
|
||||
doTest(PyBundle.message("INTN.convert.static.method.to.function"));
|
||||
}
|
||||
|
||||
private void doWithDocStringFormat(@NotNull DocStringFormat format, @NotNull Runnable runnable) {
|
||||
final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
|
||||
final DocStringFormat oldFormat = settings.getFormat();
|
||||
settings.setFormat(format);
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
finally {
|
||||
settings.setFormat(oldFormat);
|
||||
}
|
||||
}
|
||||
|
||||
private void doDocStubTest(@NotNull DocStringFormat format) {
|
||||
doWithDocStringFormat(format, new Runnable() {
|
||||
runWithDocStringFormat(format, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CodeInsightSettings.getInstance().JAVADOC_STUB_ON_ENTER = true;
|
||||
@@ -626,7 +614,7 @@ public class PyIntentionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
private void doDocReferenceTest(@NotNull DocStringFormat format) {
|
||||
doWithDocStringFormat(format, new Runnable() {
|
||||
runWithDocStringFormat(format, new Runnable() {
|
||||
public void run() {
|
||||
doTest(PyBundle.message("INTN.specify.type"));
|
||||
}
|
||||
@@ -634,7 +622,7 @@ public class PyIntentionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
private void doDocReturnTypeTest(@NotNull DocStringFormat format) {
|
||||
doWithDocStringFormat(format, new Runnable() {
|
||||
runWithDocStringFormat(format, new Runnable() {
|
||||
public void run() {
|
||||
doTest(PyBundle.message("INTN.specify.return.type"));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import com.jetbrains.python.documentation.DocStringFormat;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
|
||||
@@ -200,6 +201,34 @@ public class PyRenameTest extends PyTestCase {
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
// PY-9795
|
||||
public void testGoogleDocStringParam() {
|
||||
renameWithDocStringFormat("bar");
|
||||
}
|
||||
|
||||
// PY-9795
|
||||
public void testGoogleDocStringAttribute() {
|
||||
renameWithDocStringFormat("bar");
|
||||
}
|
||||
|
||||
// PY-9795
|
||||
public void testGoogleDocStringParamType() {
|
||||
renameWithDocStringFormat("Bar");
|
||||
}
|
||||
|
||||
// PY-9795
|
||||
public void testGoogleDocStringReturnType() {
|
||||
renameWithDocStringFormat("Bar");
|
||||
}
|
||||
|
||||
private void renameWithDocStringFormat(final String newName) {
|
||||
runWithDocStringFormat(DocStringFormat.GOOGLE, new Runnable() {
|
||||
public void run() {
|
||||
doTest(newName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doRenameConflictTest(String newName, String expectedConflict) {
|
||||
myFixture.configureByFile(RENAME_DATA_PATH + getTestName(true) + ".py");
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user