diff --git a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java index f280e347808a..774ba6cacbc7 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java @@ -290,13 +290,22 @@ public class PyPackageManagerImpl extends PyPackageManager { @NotNull protected List getPackages() throws ExecutionException { - final String output = getHelperResult(PACKAGING_TOOL, Collections.singletonList("list"), false, false, null); - final List packages = new ArrayList(parsePackagingToolOutput(output)); - if (packages.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) { - packages.addAll(Lists.newArrayList(new PyPackage(PIP, PIP_VERSION, null, Collections.emptyList()), - new PyPackage(SETUPTOOLS, SETUPTOOLS_VERSION, null, Collections.emptyList()))); + final String output; + try { + output = getHelperResult(PACKAGING_TOOL, Collections.singletonList("list"), false, false, null); } - return packages; + catch (final ProcessNotCreatedException ex) { + if (ApplicationManager.getApplication().isUnitTestMode()) { + Logger.getInstance(PyPackageManagerImpl.class).info("Not-env unit test mode, will return mock packages"); + return Lists.newArrayList(new PyPackage(PIP, PIP_VERSION, null, Collections.emptyList()), + new PyPackage(SETUPTOOLS, SETUPTOOLS_VERSION, null, Collections.emptyList())); + } + else { + throw ex; + } + } + + return parsePackagingToolOutput(output); } @Nullable