Skip to content

Commit 358f045

Browse files
committed
feat(python): add PythonContextTest class and related imports
This commit adds a new PythonContextTest class to the pycharm/src/test/kotlin directory, along with necessary imports for the test class. It also modifies the gradle.properties file to update the pycharmVersion to PC-2023.2.4.
1 parent 108fcda commit 358f045

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pluginVersion = 1.8.3-RC
1111

1212
# Supported IDEs: idea, pycharm
1313
baseIDE=idea
14-
pycharmVersion=PC-2022.2.4
14+
pycharmVersion=PC-2023.2.4
1515
golandVersion=GO-2023.3.2
1616
webstormVersion=WS-2022.2.4
1717
riderVersion=RD-2022.2.4
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package cc.unitmesh.python.context
2+
3+
import cc.unitmesh.devti.context.ClassContext
4+
import cc.unitmesh.devti.context.ClassContextProvider
5+
import com.intellij.psi.PsiFileFactory
6+
import com.intellij.testFramework.fixtures.BasePlatformTestCase
7+
import com.jetbrains.python.PythonLanguage
8+
import com.jetbrains.python.psi.PyFile
9+
10+
class PythonContextTest : BasePlatformTestCase() {
11+
private val fileFactory: PsiFileFactory get() = PsiFileFactory.getInstance(project)
12+
private val classCode = """class Person:
13+
def __init__(self, name, age):
14+
self.name = name
15+
self.age = age
16+
17+
def myfunc(self):
18+
print("Hello my name is " + self.name)
19+
20+
p1 = Person("John", 36)
21+
22+
print(p1.name)
23+
print(p1.age) """
24+
25+
fun testShould_convert_class_to_string() {
26+
val psiFile = fileFactory.createFileFromText(PythonLanguage.INSTANCE, classCode)
27+
val psiElement = (psiFile as PyFile).topLevelClasses[0]
28+
val classContext: ClassContext = ClassContextProvider(false).from(psiElement)
29+
30+
assertEquals(classContext.format(), """'package: /foo.bar
31+
class Person {
32+
33+
34+
}""");
35+
}
36+
}

rust/src/233/test/kotlin/cc/unitmesh/rust/context/RustClassContextBuilderTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package cc.unitmesh.rust.context
22

3-
import com.intellij.openapi.application.ApplicationManager
4-
import com.intellij.openapi.extensions.ExtensionPoint
53
import com.intellij.psi.util.PsiTreeUtil
64
import com.intellij.testFramework.fixtures.BasePlatformTestCase
75
import org.rust.lang.core.psi.RsEnumItem

0 commit comments

Comments
 (0)