Add resolve and rename tests

This commit is contained in:
Valentina Kiryushkina
2015-12-09 20:22:31 +03:00
parent f3d77749ba
commit c7eac47f3e
13 changed files with 68 additions and 0 deletions
@@ -0,0 +1 @@
"I want to rename this{to_be_r<caret>enamed}".format(to_be_renamed="renaming")
@@ -0,0 +1 @@
"I want to rename this{renamed}".format(renamed="renaming")
@@ -0,0 +1 @@
"I want to format" <ref>"{} as well as {kwd}".format("positional args", kwd="keyword")
@@ -0,0 +1 @@
"I want to format{} as well as" <ref>"{kwd}".format("positional args", kwd="keyword")
@@ -0,0 +1,2 @@
string = "bridge"
"my string is" <ref>"{}".format(string)
@@ -0,0 +1,2 @@
my_dict = {"fst": 12}
"formatted string with args:"<ref>"{fst}".format(**my_dict)
@@ -0,0 +1 @@
"formatted string with args:"<ref>"{fst}".format(fst=12)
@@ -0,0 +1 @@
"This is my favourite number%("<ref>"kwg)d!" % {'kwg': 4181}
@@ -0,0 +1 @@
"in percent string it's" <ref>"%s argument, but i want to pass %d arguments" % ("string", 1423)
@@ -610,4 +610,51 @@ public class PyResolveTest extends PyResolveTestCase {
public void testRMatMul() {
assertResolvesTo(PyFunction.class, "__rmatmul__");
}
//PY-2478
public void testFormatStringKWArgs() {
PsiElement target = resolve();
assertTrue(target instanceof PyKeywordArgument);
assertEquals("fst", ((PyKeywordArgument)target).getKeyword());
}
//PY-2478
public void testFormatStarArgument() {
PsiElement target = resolve();
assertTrue(target instanceof PyReferenceExpression);
assertEquals("my_dict", ((PyReferenceExpression)target).getReferencedName());
}
//PY-2478
public void testFormatPositionalArgs() {
PsiElement target = resolve();
assertTrue(target instanceof PyReferenceExpression);
assertEquals("string", target.getText());
}
//PY-2478
public void testFormatArgsAndKWargs() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
}
//PY-2478
public void testFormatArgsAndKWargs1() {
PsiElement target = resolve();
assertTrue(target instanceof PyKeywordArgument);
assertEquals("kwd", ((PyKeywordArgument)target).getKeyword());
}
//PY-2478
public void testPercentPositionalArgs() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
}
//PY-2478
public void testPercentKeyWordArgs() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertEquals("kwg", ((PyStringLiteralExpression)target).getStringValue());
}
}
@@ -902,22 +902,27 @@ public class PythonCompletionTest extends PyTestCase {
doTest();
}
//PY-3077
public void testFormatString() {
doTest();
}
//PY-3077
public void testFormatFuncArgument() {
doTest();
}
//PY-3077
public void testFormatStringFromStarArg() {
doTest();
}
//PY-3077
public void testFormatStringOutsideBraces() {
doTest();
}
//PY-3077
public void testFormatStringFromRef() {
doTest();
}
@@ -236,6 +236,11 @@ public class PyRenameTest extends PyTestCase {
renameWithDocStringFormat(DocStringFormat.NUMPY, "bar");
}
//PY-2478
public void testFormatStringKeyword() {
doTest("renamed");
}
private void renameWithDocStringFormat(DocStringFormat format, final String newName) {
runWithDocStringFormat(format, new Runnable() {
public void run() {