Search in sources :

Example 1 with AbstractPythonLegacyTestRunConfiguration

use of com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfiguration in project intellij-community by JetBrains.

the class PyUnitTestTask method runConfiguration.

protected void runConfiguration(ConfigurationFactory factory, String sdkHome, final Project project) throws Exception {
    final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration("test", factory);
    AbstractPythonLegacyTestRunConfiguration config = (AbstractPythonLegacyTestRunConfiguration) settings.getConfiguration();
    config.setSdkHome(sdkHome);
    config.setScriptName(getScriptName());
    config.setWorkingDirectory(myFixture.getTempDirPath());
    PythonSdkFlavor sdk = PythonSdkFlavor.getFlavor(sdkHome);
    if (sdk instanceof JythonSdkFlavor) {
        config.setInterpreterOptions(JythonSdkFlavor.getPythonPathCmdLineArgument(Lists.<String>newArrayList(myFixture.getTempDirPath())));
    } else {
        PythonEnvUtil.addToPythonPath(config.getEnvs(), myFixture.getTempDirPath());
    }
    configure(config);
    new WriteAction() {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            RunManagerEx.getInstanceEx(project).addConfiguration(settings, false);
            RunManagerEx.getInstanceEx(project).setSelectedConfiguration(settings);
            Assert.assertSame(settings, RunManagerEx.getInstanceEx(project).getSelectedConfiguration());
        }
    }.execute();
    runConfiguration(settings, config);
}
Also used : JythonSdkFlavor(com.jetbrains.python.sdk.flavors.JythonSdkFlavor) WriteAction(com.intellij.openapi.application.WriteAction) PythonSdkFlavor(com.jetbrains.python.sdk.flavors.PythonSdkFlavor) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AbstractPythonLegacyTestRunConfiguration(com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfiguration) Result(com.intellij.openapi.application.Result)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 JythonSdkFlavor (com.jetbrains.python.sdk.flavors.JythonSdkFlavor)1 PythonSdkFlavor (com.jetbrains.python.sdk.flavors.PythonSdkFlavor)1 AbstractPythonLegacyTestRunConfiguration (com.jetbrains.python.testing.AbstractPythonLegacyTestRunConfiguration)1