From cec6252dd786effd8a098642c85b0f00d8b67fbb Mon Sep 17 00:00:00 2001 From: Anton Efimchuk Date: Wed, 29 Apr 2026 20:56:57 +0200 Subject: [PATCH] PY-88530 Separate pytest progress from captured output Captured stdout/stderr can be emitted while pytest progress is still on the current terminal line, which makes failing test output run into the progress marker. Insert a separator before forwarding captured sections and cover both compact and verbose progress formatting with env tests. (cherry picked from commit 732a1bf27e3cafc7031ea52a2b4f44893f90735c) IJ-MR-206446 GitOrigin-RevId: 803c891d208d88015d3934f9e85fda10a1bc4aee --- .../pytest/progress_format/test_progress.py | 7 +++++ .../python/testing/PythonPyTestingTest.java | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 python/testData/testRunner/env/pytest/progress_format/test_progress.py diff --git a/python/testData/testRunner/env/pytest/progress_format/test_progress.py b/python/testData/testRunner/env/pytest/progress_format/test_progress.py new file mode 100644 index 000000000000..5f5d44884d37 --- /dev/null +++ b/python/testData/testRunner/env/pytest/progress_format/test_progress.py @@ -0,0 +1,7 @@ +def test_one(): + print("Here's some passing test output.") + pass + +def test_two(): + print("Here's some failing test output.") + assert False diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java index 4d44f3a1d312..6bd6ff3cc107 100644 --- a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java +++ b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java @@ -39,6 +39,7 @@ import com.jetbrains.python.testing.PyTestFixtureAndParametrizedTest; import com.jetbrains.python.testing.PythonTestConfigurationType; import com.jetbrains.python.testing.TestRunnerService; import com.jetbrains.python.tools.sdkTools.SdkCreationType; +import org.assertj.core.api.Assertions; import org.hamcrest.Matcher; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -1316,6 +1317,32 @@ public final class PythonPyTestingTest extends PyEnvTestCase { }); } + @Test + public void testProgressFormat() { + runPythonTest(new PyProcessWithConsoleTestTask("/testRunner/env/pytest/progress_format", SdkCreationType.EMPTY_SDK) { + + @NotNull + @Override + protected PyTestTestProcessRunner createProcessRunner() { + return new PyTestTestProcessRunner("test_progress.py", 0); + } + + @Override + protected void checkTestResults(@NotNull final PyTestTestProcessRunner runner, + @NotNull final String stdout, + @NotNull final String stderr, + @NotNull final String all, + int exitCode) { + var consoleText = runner.getAllConsoleText(); + Assertions.assertThat(consoleText.split("\n|(\r\n)")) + .containsSubsequence( + "test_progress.py::test_one PASSED [ 50%]", + "test_progress.py::test_two FAILED [100%]", + "Here's some failing test output." + ); + } + }); + } @NotNull private static String getFrameworkId() { return PyTestFactory.id;