@@ -29,11 +29,15 @@ import org.utbot.python.framework.codegen.model.PythonImport
2929import org.utbot.python.framework.codegen.model.PythonSysPathImport
3030import org.utbot.python.framework.codegen.model.PythonSystemImport
3131import 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
3334import org.utbot.python.newtyping.general.CompositeType
35+ import org.utbot.python.newtyping.getPythonAttributes
3436import org.utbot.python.newtyping.mypy.MypyBuildDirectory
3537import org.utbot.python.newtyping.mypy.MypyInfoBuild
3638import org.utbot.python.newtyping.mypy.readMypyAnnotationStorageAndInitialErrors
39+ import org.utbot.python.newtyping.pythonDescription
40+ import org.utbot.python.newtyping.pythonName
3741import org.utbot.python.utils.TemporaryFileManager
3842import org.utbot.python.utils.convertToTime
3943import 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