diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt index f8384e9d3d..ba1494ccde 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt @@ -286,10 +286,18 @@ fun getDirectoriesForSysPath( if (element != null) { val directory = element.parent if (directory is PsiDirectory) { - sources.add(directory.virtualFile) + if (sources.any { source -> + val sourcePath = source.canonicalPath + if (source.isDirectory && sourcePath != null) { + directory.virtualFile.canonicalPath?.startsWith(sourcePath) ?: false + } else { + false + } + }) { + sources.add(directory.virtualFile) + } } } - } } @@ -298,7 +306,7 @@ fun getDirectoriesForSysPath( importPath += "." return Pair( - sources.map { it.path }.toSet(), + sources.map { it.path.replace("\\", "\\\\") }.toSet(), "${importPath}${file.name}".removeSuffix(".py").toPath().joinToString(".").replace("/", File.separator) ) } \ No newline at end of file diff --git a/utbot-python/src/main/kotlin/org/utbot/python/utils/TemporaryFileManager.kt b/utbot-python/src/main/kotlin/org/utbot/python/utils/TemporaryFileManager.kt index b508f47137..2a60a9b803 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/utils/TemporaryFileManager.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/utils/TemporaryFileManager.kt @@ -15,7 +15,7 @@ object TemporaryFileManager { } fun assignTemporaryFile(fileName_: String? = null, tag: String? = null, addToCleaner: Boolean = true): File { - val fileName = fileName_ ?: ("${nextId++}_" + (tag ?: "")) + val fileName = fileName_ ?: ("tmp_${nextId++}_" + (tag ?: "")) val fullpath = Paths.get(tmpDirectory.toString(), fileName) val result = fullpath.toFile() if (addToCleaner)