diff --git a/python/testData/debug/test_step_into_with_threads.py b/python/testData/debug/test_step_into_with_threads.py new file mode 100644 index 000000000000..ed3f9b5c40f8 --- /dev/null +++ b/python/testData/debug/test_step_into_with_threads.py @@ -0,0 +1,23 @@ +from __future__ import print_function +import threading + + +class A(threading.Thread): + def foo(self): + print("foo") + + def bar(self): + print("bar") + + def baz(self): + print("baz") + + def run(self): + self.foo() # breakpoint + self.bar() + self.baz() # breakpoint + + +if __name__ == '__main__': + t = A() + t.start() \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/env/PyExecutionFixtureTestTask.java b/python/testSrc/com/jetbrains/env/PyExecutionFixtureTestTask.java index 70e11c6317b5..2e474bea578f 100644 --- a/python/testSrc/com/jetbrains/env/PyExecutionFixtureTestTask.java +++ b/python/testSrc/com/jetbrains/env/PyExecutionFixtureTestTask.java @@ -173,7 +173,7 @@ public abstract class PyExecutionFixtureTestTask extends PyTestTask { protected String getFilePath(@NotNull final String path) { final VirtualFile virtualFile = myFixture.getTempDirFixture().getFile(path); - assert virtualFile != null && virtualFile.exists() : String.format("No file in %s", myFixture.getTempDirPath()); + assert virtualFile != null && virtualFile.exists() : String.format("No file '%s' in %s", path, myFixture.getTempDirPath()); return virtualFile.getPath(); } diff --git a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java index 9c6cde8286f9..0b1ca294728e 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonDebuggerTest.java @@ -2283,7 +2283,7 @@ public class PythonDebuggerTest extends PyEnvTestCase { @Override public void before() throws Exception { - toggleBreakpoint(getScriptName(), 8); + toggleBreakpoint(getFilePath(getScriptName()), 8); } @Override @@ -2328,4 +2328,35 @@ public class PythonDebuggerTest extends PyEnvTestCase { } }); } + + @Test + public void testStepIntoWithThreads() { + runPythonTest(new PyDebuggerTask("/debug", "test_step_into_with_threads.py") { + @Override + public void before() { + toggleBreakpoint(getFilePath(getScriptName()), 15); + toggleBreakpoint(getFilePath(getScriptName()), 17); + } + + @Override + public void testing() throws Exception { + waitForPause(); + stepInto(); + waitForPause(); + stepOver(); + waitForPause(); + waitForOutput("foo"); + resume(); + waitForOutput("bar"); + waitForPause(); + stepInto(); + waitForPause(); + stepOver(); + waitForPause(); + waitForOutput("baz"); + resume(); + waitForTerminate(); + } + }); + } } diff --git a/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java b/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java index 83058a1a35ca..24587864c549 100644 --- a/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java +++ b/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java @@ -101,7 +101,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask { protected void resume() { XDebugSession currentSession = XDebuggerManager.getInstance(getProject()).getCurrentSession(); - Assert.assertTrue(currentSession.isSuspended()); + Assert.assertTrue("Resume called for session that is not in suspended state", currentSession.isSuspended()); Assert.assertEquals(0, myPausedSemaphore.availablePermits()); currentSession.resume(); @@ -110,7 +110,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask { protected void stepOver() { XDebugSession currentSession = XDebuggerManager.getInstance(getProject()).getCurrentSession(); - Assert.assertTrue(currentSession.isSuspended()); + Assert.assertTrue("Step over called for session that is not in suspended state", currentSession.isSuspended()); Assert.assertEquals(0, myPausedSemaphore.availablePermits()); currentSession.stepOver(false); @@ -119,7 +119,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask { protected void stepInto() { XDebugSession currentSession = XDebuggerManager.getInstance(getProject()).getCurrentSession(); - Assert.assertTrue(currentSession.isSuspended()); + Assert.assertTrue("Step into called for session that is not in suspended state", currentSession.isSuspended()); Assert.assertEquals(0, myPausedSemaphore.availablePermits()); currentSession.stepInto();