Skip to content

Commit fbd51ed

Browse files
committed
Fix collision variable name with module name
1 parent ee25ead commit fbd51ed

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

utbot-python/src/main/kotlin/org/utbot/python/PythonTestGenerationProcessor.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ import org.utbot.python.framework.codegen.model.PythonImport
2929
import org.utbot.python.framework.codegen.model.PythonSysPathImport
3030
import org.utbot.python.framework.codegen.model.PythonSystemImport
3131
import org.utbot.python.framework.codegen.model.PythonUserImport
32-
import org.utbot.python.newtyping.*
32+
import org.utbot.python.newtyping.PythonConcreteCompositeTypeDescription
33+
import org.utbot.python.newtyping.PythonFunctionDefinition
3334
import org.utbot.python.newtyping.general.CompositeType
35+
import org.utbot.python.newtyping.getPythonAttributes
3436
import org.utbot.python.newtyping.mypy.MypyBuildDirectory
3537
import org.utbot.python.newtyping.mypy.MypyInfoBuild
3638
import org.utbot.python.newtyping.mypy.readMypyAnnotationStorageAndInitialErrors
39+
import org.utbot.python.newtyping.pythonDescription
40+
import org.utbot.python.newtyping.pythonName
3741
import org.utbot.python.utils.TemporaryFileManager
3842
import org.utbot.python.utils.convertToTime
3943
import org.utbot.python.utils.separateTimeout
@@ -136,7 +140,8 @@ abstract class PythonTestGenerationProcessor {
136140
methodIds[testSet.method] as ExecutableId to params
137141
}.toMutableMap()
138142

139-
val allImports = if (skipImports) emptySet() else collectImports(testSets)
143+
val collectedImports = collectImports(testSets)
144+
val allImports = if (skipImports) emptySet() else collectedImports
140145

141146
val context = UtContext(this::class.java.classLoader)
142147
withUtContext(context) {
@@ -148,6 +153,7 @@ abstract class PythonTestGenerationProcessor {
148153
hangingTestsTimeout = HangingTestsTimeout(configuration.timeoutForRun),
149154
runtimeExceptionTestsBehaviour = configuration.runtimeExceptionTestsBehaviour,
150155
)
156+
codegen.context.existingVariableNames = codegen.context.existingVariableNames.addAll(collectedImports.flatMap { listOfNotNull(it.moduleName, it.rootModuleName, it.importName) })
151157
val testCode = codegen.pythonGenerateAsStringWithTestReport(
152158
testSets.map { testSet ->
153159
CgMethodTestSet(

0 commit comments

Comments
 (0)