Add test for #PY-2748

This commit is contained in:
Valentina Kiryushkina
2016-03-09 13:33:26 +03:00
parent 8a980feda7
commit d226e3bf44
11 changed files with 62 additions and 8 deletions
@@ -0,0 +1 @@
print "first is {<ref>fst}, second is {snd}".format(**{"fst": "f", "snd": "s"})
@@ -0,0 +1 @@
v = "first is {}, second is"<ref>"{}".format(("fst", ) + ("snd", ))
@@ -0,0 +1 @@
v = "first is" <ref>"{fst}, second is {snd}".format(**{"fst": "f", "snd": "s"})
@@ -0,0 +1 @@
print "first is {<ref>}, second is {}".format(*[1, 2])
@@ -0,0 +1 @@
v = "first is {}, second is {<ref>}".format(*("fst", "snd"))
@@ -0,0 +1,2 @@
reference = (1, 2)
v = "first is {<ref>}, second is {}".format(*reference)
@@ -1 +1 @@
"This is my favourite number%("<ref>"kwg)d!" % {'kwg': 4181}
"This is my favourite number%("<ref>"kwg)d!" % {'kwg': 4181}
@@ -1 +1 @@
print("<ref>%d%s" % ((("1", " "))))
print("<ref>%s%s" % ((("1", " "))))
@@ -0,0 +1 @@
v = "first is %(fst)s, second is" <ref>"%(snd)s" % ({"fst": "f", "snd": "s"})
@@ -0,0 +1,2 @@
tuple = (1, 2)
v = "first is" <ref>"%s, second is %s" % tuple
@@ -637,6 +637,36 @@ public class PyResolveTest extends PyResolveTestCase {
assertTrue(target instanceof PyKeywordArgument);
assertEquals("kwd", ((PyKeywordArgument)target).getKeyword());
}
public void testFormatStringWithPackedDictAsArgument() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertEquals("\"fst\"", target.getText());
}
public void testFormatStringWithPackedListAsArgument() {
PsiElement target = resolve();
assertTrue(target instanceof PyNumericLiteralExpression);
assertEquals("1", target.getText());
}
public void testFormatStringWithPackedTupleAsArgument() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertEquals("\"snd\"", target.getText());
}
public void testFormatStringWithBinExprAsArg() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertEquals("\"snd\"", target.getText());
}
public void testFormatStringWithRefAsArgument() {
PsiElement target = resolve();
assertEquals(null, target);
}
//PY-2478
public void testPercentPositionalArgs() {
@@ -654,22 +684,36 @@ public class PyResolveTest extends PyResolveTestCase {
// PY-18254
public void testFunctionTypeComment() {
assertResolvesTo(PyClass.class, "MyClass");
}
public void testGlobalNotDefinedAtTopLevel() {
assertResolvesTo(PyTargetExpression.class, "foo");
}
public void testPercentStringKeyWordArgWithParentheses() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertEquals("snd", ((PyStringLiteralExpression)target).getStringValue());
}
//PY-2478
public void testPercentStringBinaryStatementArg() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertTrue(((PyStringLiteralExpression)target).getStringValue().equals("1"));
assertEquals("1", ((PyStringLiteralExpression)target).getStringValue());
}
//PY-2478
public void testPercentStringArgWithRedundantParentheses() {
PsiElement target = resolve();
assertTrue(target instanceof PyStringLiteralExpression);
assertTrue(((PyStringLiteralExpression)target).getStringValue().equals("1"));
assertEquals("1", ((PyStringLiteralExpression)target).getStringValue());
}
public void testPercentStringWithRefAsArgument() {
PsiElement target = resolve();
assertEquals(null, target);
}
public void testGlobalNotDefinedAtTopLevel() {
assertResolvesTo(PyTargetExpression.class, "foo");
}
}