Skip to content

Commit ac36f11

Browse files
vlasovskikhintellij-monorepo-bot
authored andcommitted
PY-46321 Tests for Python and Python REPL in Markdown code fences
GitOrigin-RevId: f6d7f212c363f7852f69a4a54993b36774d9fed6
1 parent eaefde3 commit ac36f11

5 files changed

Lines changed: 73 additions & 0 deletions

File tree

python/python-markdown/intellij.python.markdown.iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
<content url="file://$MODULE_DIR$">
66
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
77
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
89
</content>
910
<orderEntry type="inheritedJdk" />
1011
<orderEntry type="sourceFolder" forTests="false" />
1112
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
1213
<orderEntry type="module" module-name="intellij.markdown" />
1314
<orderEntry type="module" module-name="intellij.python.psi.impl" />
1415
<orderEntry type="module" module-name="intellij.python.psi" />
16+
<orderEntry type="module" module-name="intellij.python.community.tests" scope="TEST" />
1517
</component>
1618
</module>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.jetbrains.python.markdown
2+
3+
import com.jetbrains.python.fixtures.PyTestCase
4+
5+
class PyCodeFenceTest : PyTestCase() {
6+
fun testPythonInjected() {
7+
myFixture.configureByText("a.md", """
8+
```python
9+
foo = 1
10+
f<caret>
11+
12+
```
13+
""".trimIndent())
14+
myFixture.completeBasic()
15+
assertContainsElements(lookupStrings, "foo")
16+
}
17+
18+
fun testPyInjected() {
19+
myFixture.configureByText("a.md", """
20+
```py
21+
foo = 1
22+
f<caret>
23+
24+
```
25+
""".trimIndent())
26+
myFixture.completeBasic()
27+
assertContainsElements(lookupStrings, "foo")
28+
}
29+
30+
fun testPyConInjected() {
31+
myFixture.configureByText("a.md", """
32+
```pycon
33+
>>> foo = 1
34+
>>> f<caret>
35+
36+
```
37+
""".trimIndent())
38+
myFixture.completeBasic()
39+
assertContainsElements(lookupStrings, "foo")
40+
}
41+
42+
fun testPyConNoCompletionForUndefinedName() {
43+
myFixture.configureByText("a.md", """
44+
```pycon
45+
>>> print(foo)
46+
>>> f<caret>
47+
48+
```
49+
""".trimIndent())
50+
myFixture.completeBasic()
51+
assertDoesntContain(lookupStrings, "foo")
52+
}
53+
54+
fun testPythonReplInjected() {
55+
myFixture.configureByText("a.md", """
56+
```python-repl
57+
>>> foo = 1
58+
>>> f<caret>
59+
60+
```
61+
""".trimIndent())
62+
myFixture.completeBasic()
63+
assertContainsElements(lookupStrings, "foo")
64+
}
65+
66+
private val lookupStrings: List<String>
67+
get() = myFixture.lookupElementStrings ?: emptyList()
68+
}

python/src/com/jetbrains/python/spellchecker/pythonExtras.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tuples
77
teardown
88
doctest
99
doctests
10+
pycon
1011
unittest
1112
unittests
1213
virtualenv

python/testSrc/META-INF/PyCharmCorePlugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<xi:include href="python-copyright-plugin.xml" xpointer="xpointer(/idea-plugin/*)"/>
66
<xi:include href="intellilang-python-support.xml" xpointer="xpointer(/idea-plugin/*)"/>
77
<xi:include href="python-rest-plugin.xml" xpointer="xpointer(/idea-plugin/*)"/>
8+
<xi:include href="python-markdown-plugin.xml" xpointer="xpointer(/idea-plugin/*)"/>
89
<extensions defaultExtensionNs="com.intellij">
910
<applicationService serviceInterface="com.jetbrains.python.console.PythonConsoleRunnerFactory"
1011
serviceImplementation="com.jetbrains.python.console.PydevConsoleRunnerFactory" />

python/testSrc/intellij.python.community.tests.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
<orderEntry type="library" scope="TEST" name="StreamEx" level="project" />
4141
<orderEntry type="module" module-name="intellij.platform.core.ui" scope="TEST" />
4242
<orderEntry type="module" module-name="intellij.platform.codeStyle.impl" scope="TEST" />
43+
<orderEntry type="module" module-name="intellij.python.markdown" scope="RUNTIME" />
4344
</component>
4445
</module>

0 commit comments

Comments
 (0)