summaryrefslogtreecommitdiff
path: root/python/testSrc/com
diff options
context:
space:
mode:
Diffstat (limited to 'python/testSrc/com')
-rw-r--r--python/testSrc/com/jetbrains/python/Py3CompletionTest.java20
-rw-r--r--python/testSrc/com/jetbrains/python/PyCommenterTest.java6
-rw-r--r--python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java10
-rw-r--r--python/testSrc/com/jetbrains/python/PySmartEnterTest.java10
-rw-r--r--python/testSrc/com/jetbrains/python/PyTypeTest.java10
-rw-r--r--python/testSrc/com/jetbrains/python/PythonCompletionTest.java32
-rw-r--r--python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java5
-rw-r--r--python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java5
8 files changed, 92 insertions, 6 deletions
diff --git a/python/testSrc/com/jetbrains/python/Py3CompletionTest.java b/python/testSrc/com/jetbrains/python/Py3CompletionTest.java
index 1409ff490005..ca7c3c2649f3 100644
--- a/python/testSrc/com/jetbrains/python/Py3CompletionTest.java
+++ b/python/testSrc/com/jetbrains/python/Py3CompletionTest.java
@@ -18,6 +18,7 @@ package com.jetbrains.python;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.testFramework.LightProjectDescriptor;
import com.jetbrains.python.fixtures.PyTestCase;
+import com.jetbrains.python.psi.LanguageLevel;
import java.util.List;
@@ -73,4 +74,23 @@ public class Py3CompletionTest extends PyTestCase {
myFixture.completeBasic();
return myFixture.getLookupElementStrings();
}
+
+ // PY-4073
+ public void testSpecialFunctionAttributesPy3() throws Exception {
+ setLanguageLevel(LanguageLevel.PYTHON32);
+ try {
+ List<String> suggested = doTestByText("def func(): pass; func.func_<caret>");
+ assertNotNull(suggested);
+ assertEmpty(suggested);
+
+ suggested = doTestByText("def func(): pass; func.__<caret>");
+ assertNotNull(suggested);
+ assertContainsElements(suggested, "__defaults__", "__globals__", "__closure__",
+ "__code__", "__name__", "__doc__", "__dict__", "__module__");
+ assertContainsElements(suggested, "__annotations__", "__kwdefaults__");
+ }
+ finally {
+ setLanguageLevel(null);
+ }
+ }
}
diff --git a/python/testSrc/com/jetbrains/python/PyCommenterTest.java b/python/testSrc/com/jetbrains/python/PyCommenterTest.java
index 651311e4fde9..1ce9202101ac 100644
--- a/python/testSrc/com/jetbrains/python/PyCommenterTest.java
+++ b/python/testSrc/com/jetbrains/python/PyCommenterTest.java
@@ -15,8 +15,6 @@
*/
package com.jetbrains.python;
-import com.intellij.codeInsight.actions.CodeInsightAction;
-import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.IdeActions;
import com.jetbrains.python.fixtures.PyTestCase;
@@ -34,9 +32,7 @@ public class PyCommenterTest extends PyTestCase {
private void doTest() {
myFixture.configureByFile("commenter/" + getTestName(true) + ".py");
- CodeInsightAction action = (CodeInsightAction) ActionManager.getInstance().getAction(IdeActions.ACTION_COMMENT_LINE);
- action.actionPerformedImpl(myFixture.getFile().getProject(), myFixture.getEditor());
+ myFixture.performEditorAction(IdeActions.ACTION_COMMENT_LINE);
myFixture.checkResultByFile("commenter/" + getTestName(true) + "_after.py", true);
-
}
}
diff --git a/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java b/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java
index e942388659ba..4585832844eb 100644
--- a/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java
+++ b/python/testSrc/com/jetbrains/python/PyMultiFileResolveTest.java
@@ -363,4 +363,14 @@ public class PyMultiFileResolveTest extends PyMultiFileResolveTestCase {
public void testFromPackageModuleImportStarElementNamedAsModule() {
assertResolvesTo(PyFunction.class, "foo");
}
+
+ // PY-13140
+ public void testModulePrivateName() {
+ assertNull(doResolve());
+ }
+
+ // PY-13140
+ public void testModulePrivateNameInDunderAll() {
+ assertResolvesTo(PyTargetExpression.class, "_private_name");
+ }
}
diff --git a/python/testSrc/com/jetbrains/python/PySmartEnterTest.java b/python/testSrc/com/jetbrains/python/PySmartEnterTest.java
index 959b1f752ee8..b8421c9d7e18 100644
--- a/python/testSrc/com/jetbrains/python/PySmartEnterTest.java
+++ b/python/testSrc/com/jetbrains/python/PySmartEnterTest.java
@@ -169,4 +169,14 @@ public class PySmartEnterTest extends PyTestCase {
pyCodeInsightSettings.INSERT_TYPE_DOCSTUB = oldInsertType;
}
}
+
+ // PY-12877
+ public void testWithTargetOmitted() {
+ doTest();
+ }
+
+ // PY-12877
+ public void testWithTargetIncomplete() {
+ doTest();
+ }
}
diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java
index 81b4aa46629e..88243f065a3b 100644
--- a/python/testSrc/com/jetbrains/python/PyTypeTest.java
+++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java
@@ -399,6 +399,16 @@ public class PyTypeTest extends PyTestCase {
"expr = x.start\n");
TypeEvalContext context = getTypeEvalContext(expr);
PyType actual = context.getType(expr);
+ assertNotNull(actual);
+ assertInstanceOf(actual, PyClassType.class);
+ assertEquals("int", actual.getName());
+ }
+
+ public void testUndefinedPropertyOfUnionType() {
+ PyExpression expr = parseExpr("x = 42 if True else 'spam'\n" +
+ "expr = x.foo\n");
+ TypeEvalContext context = getTypeEvalContext(expr);
+ PyType actual = context.getType(expr);
assertNull(actual);
}
diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java
index b57ae35baa17..f365eea4da34 100644
--- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java
@@ -161,7 +161,7 @@ public class PythonCompletionTest extends PyTestCase {
final LookupElement[] elements = myFixture.completeBasic();
assertNotNull(elements);
assertEquals(1, elements.length);
- assertEquals("children", elements [0].getLookupString());
+ assertEquals("children", elements[0].getLookupString());
}
public void testImportModule() {
@@ -613,6 +613,36 @@ public class PythonCompletionTest extends PyTestCase {
" __meta<caret>\n");
myFixture.checkResult("class C(object):\n" +
" __metaclass__ = \n");
+ }
+
+ // PY-13140
+ public void testModulePrivateNamesCompletedInsideImport() {
+ myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
+ myFixture.configureByFile("a.py");
+ myFixture.completeBasic();
+ List<String> suggested = myFixture.getLookupElementStrings();
+ assertNotNull(suggested);
+ assertContainsElements(suggested, "normal_name", "_private_name", "__magic_name__");
+ }
+ // PY-4073
+ public void testSpecialFunctionAttributes() throws Exception {
+ setLanguageLevel(LanguageLevel.PYTHON27);
+ try {
+ List<String> suggested = doTestByText("def func(): pass; func.func_<caret>");
+ assertNotNull(suggested);
+ assertContainsElements(suggested,
+ "func_defaults", "func_globals", "func_closure",
+ "func_code", "func_name", "func_doc", "func_dict");
+
+ suggested = doTestByText("def func(): pass; func.__<caret>");
+ assertNotNull(suggested);
+ assertContainsElements(suggested, "__defaults__", "__globals__", "__closure__",
+ "__code__", "__name__", "__doc__", "__dict__", "__module__");
+ assertDoesntContain(suggested, "__annotations__", "__kwdefaults__");
+ }
+ finally {
+ setLanguageLevel(null);
+ }
}
}
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
index e614edd8e627..0c5e87ab1001 100644
--- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java
@@ -366,6 +366,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
doMultiFileTest();
}
+ // PY-13140
+ public void testPrivateModuleNames() {
+ doMultiFileTest();
+ }
+
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {
diff --git a/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java
index 3dfa4a39bc85..833f71e8452a 100644
--- a/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java
+++ b/python/testSrc/com/jetbrains/python/intentions/PyConvertFormatOperatorToMethodIntentionTest.java
@@ -38,4 +38,9 @@ public class PyConvertFormatOperatorToMethodIntentionTest extends PyIntentionTes
public void testUnicode() {
doTest(PyBundle.message("INTN.replace.with.method"), LanguageLevel.PYTHON26);
}
+
+ // PY-9176
+ public void testConcatenated() {
+ doTest(PyBundle.message("INTN.replace.with.method"), LanguageLevel.PYTHON26);
+ }
} \ No newline at end of file