Skip to content

Commit

Permalink
Make some test with things we should support fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Oct 14, 2024
1 parent 5edd8b4 commit 5e8e6de
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,21 @@ public static boolean isUnix() {

// File is something as Pydev/plugins/org.python.pydev.core
// We want something as: Pydev/plugins/
file = file.getParentFile();
if (new File(file, "org.python.pydev.core").exists()) {
TEST_PYDEV_BASE_LOC = file.toString().replace("\\", "/");
if (!TEST_PYDEV_BASE_LOC.endsWith("/")) {
TEST_PYDEV_BASE_LOC += '/';
for (int i = 0; i < 10; i++) {
file = file.getParentFile();
File corePlugin = new File(file, "org.python.pydev.core");
if (corePlugin.exists()) {
TEST_PYDEV_BASE_LOC = file.toString().replace("\\", "/");
if (!TEST_PYDEV_BASE_LOC.endsWith("/")) {
TEST_PYDEV_BASE_LOC += '/';
}
break;
}
} else {
}
if (TEST_PYDEV_BASE_LOC == null) {
System.err.println(
"TEST_PYDEV_BASE_LOC variable MUST be set in " + propertiesFile + " to run tests.");
"TEST_PYDEV_BASE_LOC variable MUST be set in " + propertiesFile
+ " to run tests (unable to auto-discover value).");
}

} else if (!new File(TEST_PYDEV_BASE_LOC).exists()) {
Expand Down Expand Up @@ -234,6 +240,9 @@ public static boolean isUnix() {
if (!TEST_PYSRC_TESTING_LOC.endsWith("/")) {
throw new RuntimeException("Expecting TEST_PYSRC_TESTING_LOC to end with '/'");
}
if (!new File(TEST_PYSRC_TESTING_LOC).exists()) {
throw new RuntimeException("Expected TEST_PYSRC_TESTING_LOC: " + TEST_PYSRC_TESTING_LOC + " to exist!");
}

if (TEST_PYSRC_NAVIGATOR_LOC == null) {
TEST_PYSRC_NAVIGATOR_LOC = TEST_PYDEV_BASE_LOC + "org.python.pydev/tests_navigator/pysrc/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ public void testFStrings() {
+ "";

// TODO: Support this!
// SimpleNode ast = parseLegalDocStr(s);
// parseLegalDocStr(s);

}

public void testTypeVarSyntax() {
String s = """
def f312[T](e: T) -> None: ...
print(f312)
""";
// TODO: Support this!
// parseLegalDocStr(s);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void main(String[] args) {
//DEBUG_TESTS_BASE = true;
PythonCompletionWithoutBuiltinsTest test = new PythonCompletionWithoutBuiltinsTest();
test.setUp();
test.testGrammar2AbsoluteAndRelativeImports();
test.testAnnotatedCompletion();
test.tearDown();
System.out.println("Finished");

Expand Down Expand Up @@ -3558,4 +3558,18 @@ public void testEnumCustom2() throws Exception {
requestCompl(s, s.length(), -1, new String[] { "name", "value", "signal_type" });
}

public void testAnnotatedCompletion() throws Exception {
String s = """
from typing import Annotated
class C:
def method1(self) -> None:
pass
def f2(c: Annotated[C, ...]) -> None:
c.
""".strip();
requestCompl(s, s.length(), -1, new String[] { "method1()" });
}

}

0 comments on commit 5e8e6de

Please sign in to comment.