diff --git a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java index b6e88780f2ba..499db83a1e2c 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java @@ -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()) { diff --git a/python/testData/debug/runner.py b/python/testData/debug/runner.py new file mode 100644 index 000000000000..cfb47d50328c --- /dev/null +++ b/python/testData/debug/runner.py @@ -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) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 9646906b89d9..c27cfbeea352 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -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"); + } + }); + } }