Add test for '-m package' interpreter option in debug mode (PY-15230)

Currently -m is removed while package stays in the options. This breaks the process launch.
This commit is contained in:
Dmitry Trofimov
2016-10-30 13:05:30 +01:00
parent eae806e4e2
commit d16cac767d
3 changed files with 59 additions and 27 deletions
@@ -33,7 +33,6 @@ import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.remote.RemoteSdkAdditionalData;
import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
@@ -340,7 +339,7 @@ public class PyDebugRunner extends GenericProgramRunner {
public static void configureCommonDebugParameters(@NotNull Project project,
@NotNull ParamsGroup debugParams) {
if (isModule) {
debugParams.addParameter("--module");
debugParams.addParameter(MODULE_PARAM);
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
+11
View File
@@ -0,0 +1,11 @@
import runpy
import sys
print(sys.argv)
x = 1
program = sys.argv[1]
sys.argv = sys.argv[1:]
runpy.run_path(program)
@@ -26,6 +26,7 @@ import com.jetbrains.python.debugger.PyExceptionBreakpointType;
import com.jetbrains.python.debugger.pydev.PyDebugCallback;
import com.jetbrains.python.debugger.settings.PyDebuggerSettings;
import com.jetbrains.python.debugger.settings.PySteppingFilter;
import com.jetbrains.python.sdk.PythonEnvUtil;
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
import com.jetbrains.python.sdkTools.SdkCreationType;
import org.jetbrains.annotations.NotNull;
@@ -44,33 +45,39 @@ import static org.junit.Assert.assertNull;
*/
public class PythonDebuggerTest extends PyEnvTestCase {
private class BreakpointStopAndEvalTask extends PyDebuggerTask {
public BreakpointStopAndEvalTask() {
super("/debug", "test1.py");
}
@Override
public void before() throws Exception {
toggleBreakpoint(getFilePath(getScriptName()), 3);
}
@Override
public void testing() throws Exception {
waitForPause();
eval("i").hasValue("0");
resume();
waitForPause();
eval("i").hasValue("1");
resume();
waitForPause();
eval("i").hasValue("2");
}
}
@Test
public void testBreakpointStopAndEval() throws Exception {
runPythonTest(new PyDebuggerTask("/debug", "test1.py") {
@Override
public void before() throws Exception {
toggleBreakpoint(getFilePath(getScriptName()), 3);
}
@Override
public void testing() throws Exception {
waitForPause();
eval("i").hasValue("0");
resume();
waitForPause();
eval("i").hasValue("1");
resume();
waitForPause();
eval("i").hasValue("2");
}
});
runPythonTest(new BreakpointStopAndEvalTask());
}
@Test
@@ -1125,5 +1132,20 @@ public class PythonDebuggerTest extends PyEnvTestCase {
}
});
}
@Staging
@Test
public void testModuleInterpreterOption() throws Exception {
runPythonTest(new BreakpointStopAndEvalTask() {
@Override
public void before() throws Exception {
super.before();
PythonEnvUtil.addToPythonPath(myRunConfiguration.getEnvs(), new File(getFilePath(getScriptName())).getParent());
myRunConfiguration.setInterpreterOptions("-m runner");
}
});
}
}