|
| 1 | +From: Riken Maharjan <rmaharjan@microsoft.com> |
| 2 | +Date: Tue, 28 Apr 2025 10:00:00 -0700 |
| 3 | +Subject: Fix Pytest Output issue for Forked Tests |
| 4 | + |
| 5 | +diff --git a/testing/test_xfail_behavior.py b/testing/test_xfail_behavior.py |
| 6 | +index ef00385..15edd93 100644 |
| 7 | +--- a/testing/test_xfail_behavior.py |
| 8 | ++++ b/testing/test_xfail_behavior.py |
| 9 | +@@ -6,6 +6,7 @@ |
| 10 | + |
| 11 | + IS_PYTEST4_PLUS = int(pytest.__version__[0]) >= 4 # noqa: WPS609 |
| 12 | + FAILED_WORD = "FAILED" if IS_PYTEST4_PLUS else "FAIL" |
| 13 | ++PYTEST_GTE_7_2 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 2) # type: ignore[attr-defined] |
| 14 | + |
| 15 | + pytestmark = pytest.mark.skipif( # pylint: disable=invalid-name |
| 16 | + not hasattr(os, "fork"), # noqa: WPS421 |
| 17 | +@@ -68,10 +69,12 @@ def test_xfail(is_crashing, is_strict, testdir): |
| 18 | + ) |
| 19 | + ) |
| 20 | + reason_string = ( |
| 21 | +- " reason: The process gets terminated; " |
| 22 | ++ "reason: The process gets terminated; " |
| 23 | + "pytest-forked reason: " |
| 24 | + "*:*: running the test CRASHED with signal {sig_num:d}".format(**locals()) |
| 25 | + ) |
| 26 | ++ if expected_lowercase == "xfailed" and PYTEST_GTE_7_2: |
| 27 | ++ short_test_summary += " - " + reason_string |
| 28 | + total_summary_line = "*==== 1 {expected_lowercase!s} in 0.*s* ====*".format( |
| 29 | + **locals() |
| 30 | + ) |
| 31 | +@@ -95,7 +98,7 @@ def test_xfail(is_crashing, is_strict, testdir): |
| 32 | + ) |
| 33 | + if expected_lowercase == "xpassed" and expected_word == FAILED_WORD: |
| 34 | + # XPASS(strict) |
| 35 | +- expected_lines += (reason_string,) |
| 36 | ++ expected_lines += (" " + reason_string,) |
| 37 | + expected_lines += (total_summary_line,) |
| 38 | + |
| 39 | + test_module = testdir.makepyfile( |
0 commit comments