mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
PyCharm: Add Poetry support into tests.
Current implementation doesn't destroy envs, created by tests, so it might be useful to create a fixture to do that as it is done for Conda. This change makes `VanillaPythonEnvExtension` to look for Python with Poetry and install its path to `PropertiesComponent`. See `PoetryTest` as an example GitOrigin-RevId: 3d66a46a8e9b80d85e7bf47b1bf27eeb562c218b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2b039aab98
commit
7ad77319e3
@@ -30,12 +30,12 @@ typealias PathToPythonBinary = Path
|
||||
*/
|
||||
sealed class PythonType<T : Any>(private val tag: @NonNls String) {
|
||||
|
||||
suspend fun getTestEnvironment(): Result<Pair<T, AutoCloseable>> =
|
||||
suspend fun getTestEnvironment(vararg additionalTags: @NonNls String): Result<Pair<T, AutoCloseable>> =
|
||||
PyEnvTestSettings
|
||||
.fromEnvVariables()
|
||||
.pythons
|
||||
.map { it.toPath() }
|
||||
.firstOrNull { typeMatchesEnv(it) }
|
||||
.firstOrNull { typeMatchesEnv(it, *additionalTags) }
|
||||
?.let { envDir ->
|
||||
Result.success(pythonPathToEnvironment(Path.of(
|
||||
PythonSdkUtil.getPythonExecutable(envDir.toString())
|
||||
@@ -90,12 +90,12 @@ sealed class PythonType<T : Any>(private val tag: @NonNls String) {
|
||||
|
||||
|
||||
@RequiresBackgroundThread
|
||||
private fun typeMatchesEnv(env: Path): Boolean {
|
||||
private fun typeMatchesEnv(env: Path, vararg additionalTags: @NonNls String): Boolean {
|
||||
val envTags = PyEnvTestCase.loadEnvTags(env.toString())
|
||||
|
||||
for (badTag in PythonType::class.sealedSubclasses.filterNot { it.isInstance(this) }.map { it.objectInstance!!.tag }) {
|
||||
if (badTag in envTags) return false
|
||||
}
|
||||
return tag in envTags
|
||||
return tag in envTags && additionalTags.all { it in envTags }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user