diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt index b64ea37755dc..c635fd23aaee 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt @@ -61,7 +61,7 @@ class PyUniversalNoseTestConfiguration(project: Project, factory: PyUniversalNos override fun isFrameworkInstalled() = VFSTestFrameworkListener.getInstance().isNoseTestInstalled(sdk) //https://github.com/nose-devs/nose/issues/1042 - override fun treatFoldersAsPackages(anchor: PsiElement) = true + override fun packageOnlyIfInitPy(anchor: PsiElement) = true } object PyUniversalNoseTestFactory : PyUniversalTestFactory() { diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt index 7f5549cc8dfe..76aa3c6cc688 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt @@ -529,7 +529,7 @@ abstract class PyUniversalTestConfiguration(project: Project, /** * When checking if configuration is ok we need to know if folders could be packages: i.e. if foo.bar requires init.py in foo to work */ - open fun treatFoldersAsPackages(anchor: PsiElement) = (!LanguageLevel.forElement(anchor).isPy3K) + open fun packageOnlyIfInitPy(anchor: PsiElement) = (!LanguageLevel.forElement(anchor).isPy3K) } private fun isTestFile(file: PyFile): Boolean { @@ -595,7 +595,7 @@ object PyUniversalTestsConfigurationProducer : AbstractPythonTestConfigurationPr private fun getTargetForConfig(configuration: PyUniversalTestConfiguration, baseElement: PsiElement, fixConfiguration: Boolean = false): ConfigurationTarget? { - val setRelative = (fixConfiguration && configuration.treatFoldersAsPackages(baseElement)) + val setRelative = (fixConfiguration && configuration.packageOnlyIfInitPy(baseElement)) var element = baseElement // Go up until we reach top of the file diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt index 66e7866b0dc6..5b5573ed2282 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt @@ -24,6 +24,7 @@ import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.openapi.options.SettingsEditor import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.psi.PsiElement import com.jetbrains.python.PythonHelper import com.jetbrains.python.testing.PythonTestConfigurationsModel @@ -74,6 +75,9 @@ class PyUniversalUnitTestConfiguration(project: Project, factory: PyUniversalUni } override fun isFrameworkInstalled() = true //Unittest is always available + + // See loader.py: is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py')) + override fun packageOnlyIfInitPy(anchor: PsiElement) = true } object PyUniversalUnitTestFactory : PyUniversalTestFactory() {