diff --git a/python/python-sdk/src/com/jetbrains/python/pathValidation/PathValidator.kt b/python/python-sdk/src/com/jetbrains/python/pathValidation/PathValidator.kt index 750a350b75b4..1401d9c4eeb2 100644 --- a/python/python-sdk/src/com/jetbrains/python/pathValidation/PathValidator.kt +++ b/python/python-sdk/src/com/jetbrains/python/pathValidation/PathValidator.kt @@ -52,7 +52,8 @@ class ValidationRequest(@NonNls internal val path: String?, private fun isAbsolutePath(path: String): Boolean = when (platformAndRoot.platform) { Platform.UNIX -> path.startsWith("/") - Platform.WINDOWS -> OSAgnosticPathUtil.isAbsoluteDosPath(path) + // On Windows user may create project in \\wsl + Platform.WINDOWS -> OSAgnosticPathUtil.isAbsoluteDosPath(path) || path.startsWith("\\\\wsl") } } diff --git a/python/python-sdk/tests/com/jetbrains/python/tests/ValidationRequestTest.kt b/python/python-sdk/tests/com/jetbrains/python/tests/ValidationRequestTest.kt new file mode 100644 index 000000000000..fdf0f5f411f8 --- /dev/null +++ b/python/python-sdk/tests/com/jetbrains/python/tests/ValidationRequestTest.kt @@ -0,0 +1,29 @@ +package com.jetbrains.python.tests + +import com.intellij.execution.Platform +import com.jetbrains.python.pathValidation.PlatformAndRoot +import com.jetbrains.python.pathValidation.ValidationRequest +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Test + +class ValidationRequestTest { + + @Test + fun testAbsolutePath() { + if (PlatformAndRoot.local.platform == Platform.UNIX) { + assertNull("No error must be returned", + ValidationRequest("/", "", PlatformAndRoot.local, null).validate { null }) + assertNotNull("Path not absolute, but no error returned", + ValidationRequest("abc", "", PlatformAndRoot.local, null).validate { null }) + } + else { + assertNull("No error must be returned", + ValidationRequest("\\\\wsl$\\asdad", "", PlatformAndRoot.local, null).validate { null }) + assertNull("No error must be returned", + ValidationRequest("c:\\", "", PlatformAndRoot.local, null).validate { null }) + assertNotNull("Path not absolute, but no error returned", + ValidationRequest("abc", "", PlatformAndRoot.local, null).validate { null }) + } + } +} \ No newline at end of file