generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
pycharm/src/test/kotlin/cc/unitmesh/python/context/PythonContextTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cc.unitmesh.python.context | ||
|
||
import cc.unitmesh.devti.context.ClassContext | ||
import cc.unitmesh.devti.context.ClassContextProvider | ||
import com.intellij.psi.PsiFileFactory | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase | ||
import com.jetbrains.python.PythonLanguage | ||
import com.jetbrains.python.psi.PyFile | ||
|
||
class PythonContextTest : BasePlatformTestCase() { | ||
private val fileFactory: PsiFileFactory get() = PsiFileFactory.getInstance(project) | ||
private val classCode = """class Person: | ||
def __init__(self, name, age): | ||
self.name = name | ||
self.age = age | ||
def myfunc(self): | ||
print("Hello my name is " + self.name) | ||
p1 = Person("John", 36) | ||
print(p1.name) | ||
print(p1.age) """ | ||
|
||
fun testShould_convert_class_to_string() { | ||
val psiFile = fileFactory.createFileFromText(PythonLanguage.INSTANCE, classCode) | ||
val psiElement = (psiFile as PyFile).topLevelClasses[0] | ||
val classContext: ClassContext = ClassContextProvider(false).from(psiElement) | ||
|
||
assertEquals(classContext.format(), """'package: /foo.bar | ||
class Person { | ||
}"""); | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
rust/src/233/test/kotlin/cc/unitmesh/rust/context/RustClassContextBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters