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
This commit is contained in:
Anton Efimchuk
2026-07-08 18:21:15 +00:00
committed by intellij-monorepo-bot
parent fa8ce69900
commit cec6252dd7
2 changed files with 34 additions and 0 deletions
@@ -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
@@ -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<PyTestTestProcessRunner>("/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;