Skip to content

Commit 120db6e

Browse files
authored
Fix failures report when test is marked as thread-unsafe (#71)
1 parent 101f325 commit 120db6e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/pytest_run_parallel/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def pytest_report_teststatus(report, config):
249249
)
250250
if report.outcome == "failed":
251251
return (
252-
"passed",
252+
"failed",
253253
"x",
254254
f"FAILED ([thread-unsafe]: {props['thread_unsafe_reason']})",
255255
)

tests/test_run_parallel.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,3 +1084,24 @@ def test_function_recurse_on_assign(num_parallel_threads):
10841084
"*::test_function_recurse_on_assign PASSED*",
10851085
]
10861086
)
1087+
1088+
1089+
def test_failed_thread_unsafe(pytester):
1090+
pytester.makepyfile("""
1091+
import pytest
1092+
1093+
@pytest.mark.thread_unsafe
1094+
def test1():
1095+
assert False
1096+
""")
1097+
1098+
result = pytester.runpytest("--parallel-threads=10", "-v")
1099+
assert result.ret == 1
1100+
print(result.stdout)
1101+
result.stdout.fnmatch_lines(
1102+
[
1103+
"*::test1 FAILED *thread-unsafe*: uses thread_unsafe marker*",
1104+
"* FAILURES *",
1105+
"*1 failed*",
1106+
]
1107+
)

0 commit comments

Comments
 (0)