mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-77360: Introduce tests for PyDocStringGenerator
GitOrigin-RevId: f230b0f4069ea0c2c0032f4668051cfd23aa010a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
86334df8ad
commit
3c88d3679f
@@ -0,0 +1,13 @@
|
||||
"""
|
||||
This is documentation.
|
||||
It has multiple lines.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class Test:
|
||||
pass
|
||||
|
||||
def foo():
|
||||
pass
|
||||
@@ -0,0 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class Test:
|
||||
pass
|
||||
|
||||
def foo():
|
||||
pass
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# some comments
|
||||
"""
|
||||
This is documentation.
|
||||
It has multiple lines.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class Test:
|
||||
pass
|
||||
|
||||
def foo():
|
||||
pass
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# some comments
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class Test:
|
||||
pass
|
||||
|
||||
def foo():
|
||||
pass
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.documentation.docstings
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
import com.jetbrains.python.documentation.docstrings.PyDocstringGenerator
|
||||
import com.jetbrains.python.fixtures.PyTestCase
|
||||
import com.jetbrains.python.psi.PyFile
|
||||
|
||||
@TestFor(classes = [PyDocstringGenerator::class])
|
||||
@TestDataPath("\$CONTENT_ROOT/../testData/docGeneration")
|
||||
class PyDocstringGeneratorTestCase : PyTestCase() {
|
||||
override fun getTestDataPath(): String = super.getTestDataPath() + "/docGeneration"
|
||||
|
||||
fun testModuleLevel() = doTestModuleLevelDocumentation()
|
||||
|
||||
fun testModuleLevelAfterComments() = doTestModuleLevelDocumentation()
|
||||
|
||||
private fun doTestModuleLevelDocumentation() {
|
||||
val testName = getTestName(true)
|
||||
val file = myFixture.configureByFile("$testName.py")
|
||||
if (file !is PyFile) {
|
||||
error("Incorrect file. Must be a Python file.")
|
||||
}
|
||||
WriteCommandAction.runWriteCommandAction(myFixture.project) {
|
||||
val docstringGenerator = PyDocstringGenerator.forDocStringOwner(file)
|
||||
docstringGenerator.buildAndInsert(DOCUMENTATION)
|
||||
}
|
||||
myFixture.checkResultByFile("$testName.after.py")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DOCUMENTATION = "\"\"\"\n" +
|
||||
"This is documentation.\n" +
|
||||
"It has multiple lines.\n" +
|
||||
"\"\"\""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user