mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Chandes to manage.py model, improved usability of ctrl+alt+r(PY-450), added some tests
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
from django.core.management import execute_manager
|
||||
from pycharm import django_settings_tests
|
||||
|
||||
if __name__ == "__main__":
|
||||
if sys.platform == 'win32':
|
||||
import getpass
|
||||
import warnings
|
||||
getpass.getpass = getpass.fallback_getpass
|
||||
warnings.simplefilter("ignore", category=getpass.GetPassWarning)
|
||||
execute_manager(django_settings_tests)
|
||||
@@ -0,0 +1 @@
|
||||
TEST_RUNNER = 'pycharm.django_test_runner.run_tests'
|
||||
Binary file not shown.
@@ -17,6 +17,8 @@
|
||||
<orderEntry type="module" module-name="dom-impl" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="JavaScriptLanguage" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="CSS" scope="RUNTIME" />
|
||||
<orderEntry type="library" name="commons-collections" level="project" />
|
||||
<orderEntry type="library" name="commons-lang" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.jetbrains.python.testing;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.SimpleJavaParameters;
|
||||
import com.intellij.execution.process.CapturingProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutput;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SimpleJavaSdkType;
|
||||
import com.intellij.util.SystemProperties;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
public class JythonUnitTestUtil {
|
||||
public static ProcessOutput runJython(String workDir, String pythonPath, String... args) throws ExecutionException {
|
||||
final SimpleJavaSdkType sdkType = new SimpleJavaSdkType();
|
||||
final Sdk ideaJdk = sdkType.createJdk("tmp", SystemProperties.getJavaHome());
|
||||
SimpleJavaParameters parameters = new SimpleJavaParameters();
|
||||
parameters.setJdk(ideaJdk);
|
||||
parameters.setMainClass("org.python.util.jython");
|
||||
|
||||
File jythonJar = new File(PathManager.getHomePath(), "python/lib/jython.jar");
|
||||
parameters.getClassPath().add(jythonJar.getPath());
|
||||
|
||||
parameters.getProgramParametersList().add("-Dpython.path=" + pythonPath + ";" + workDir);
|
||||
parameters.getProgramParametersList().addAll(args);
|
||||
parameters.setWorkingDirectory(workDir);
|
||||
|
||||
final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(sdkType.getVMExecutablePath(ideaJdk), parameters, false);
|
||||
final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine.createProcess());
|
||||
return processHandler.runProcess();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import com.jetbrains.python.testing.JythonUnitTestUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -75,7 +76,7 @@ public class PyTestRunnerTest extends LightPlatformTestCase {
|
||||
List<String> allArgs = new ArrayList<String>();
|
||||
allArgs.add(utRunner.getPath());
|
||||
Collections.addAll(allArgs, args);
|
||||
final ProcessOutput output = runJython(workDir, helpersDir.getPath(), ArrayUtil.toStringArray(allArgs));
|
||||
final ProcessOutput output = JythonUnitTestUtil.runJython(workDir, helpersDir.getPath(), ArrayUtil.toStringArray(allArgs));
|
||||
assertEquals(output.getStderr(), 0, splitLines(output.getStderr()).length);
|
||||
return splitLines(output.getStdout());
|
||||
}
|
||||
@@ -90,23 +91,4 @@ public class PyTestRunnerTest extends LightPlatformTestCase {
|
||||
}
|
||||
return ArrayUtil.toStringArray(result);
|
||||
}
|
||||
|
||||
private static ProcessOutput runJython(String workDir, String pythonPath, String... args) throws ExecutionException {
|
||||
final SimpleJavaSdkType sdkType = new SimpleJavaSdkType();
|
||||
final Sdk ideaJdk = sdkType.createJdk("tmp", SystemProperties.getJavaHome());
|
||||
SimpleJavaParameters parameters = new SimpleJavaParameters();
|
||||
parameters.setJdk(ideaJdk);
|
||||
parameters.setMainClass("org.python.util.jython");
|
||||
|
||||
File jythonJar = new File(PathManager.getHomePath(), "python/lib/jython.jar");
|
||||
parameters.getClassPath().add(jythonJar.getPath());
|
||||
|
||||
parameters.getProgramParametersList().add("-Dpython.path=" + pythonPath + ";" + workDir);
|
||||
parameters.getProgramParametersList().addAll(args);
|
||||
parameters.setWorkingDirectory(workDir);
|
||||
|
||||
final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(sdkType.getVMExecutablePath(ideaJdk), parameters, false);
|
||||
final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine.createProcess());
|
||||
return processHandler.runProcess();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user