|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +"""TEMPORARY: deliberate failures that exercise the CI failure-visibility changes. |
| 5 | +
|
| 6 | +REMOVE THIS FILE BEFORE MERGE. |
| 7 | +
|
| 8 | +Each test fails in a different way, so one CI run shows how the folded log, the |
| 9 | +reordered short test summary, and the GitHub annotations render: |
| 10 | +
|
| 11 | +* a plain assertion in a parallel test (pytest-run-parallel reports it as ERROR) |
| 12 | +* two failing cases of a parametrized test, with a passing case between them |
| 13 | +* a thread-unsafe test that raises (the FAILED path, outside the parallel runner) |
| 14 | +* an assertion with a multi-line diff |
| 15 | +* a fixture error (ERROR at setup; the annotate plugin covers only the call phase) |
| 16 | +* a failure preceded by a warning (the warning must not become an annotation) |
| 17 | +* an exception raised inside a helper (two traceback frames) |
| 18 | +""" |
| 19 | + |
| 20 | +import warnings |
| 21 | + |
| 22 | +import pytest |
| 23 | + |
| 24 | + |
| 25 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 26 | +def test_injected_plain_assert(): |
| 27 | + assert 1 + 1 == 3 |
| 28 | + |
| 29 | + |
| 30 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 31 | +@pytest.mark.parametrize("value", [1, 2, 3]) |
| 32 | +def test_injected_parametrized(value): |
| 33 | + assert value % 2 == 0, f"value {value} is odd" |
| 34 | + |
| 35 | + |
| 36 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 37 | +@pytest.mark.thread_unsafe(reason="injected: exercises the non-parallel FAILED path") |
| 38 | +def test_injected_thread_unsafe(): |
| 39 | + raise RuntimeError("injected failure outside the parallel runner") |
| 40 | + |
| 41 | + |
| 42 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 43 | +def test_injected_dict_diff(): |
| 44 | + expected = {"a": 1, "b": 2, "c": 3} |
| 45 | + actual = {"a": 1, "b": 20, "d": 4} |
| 46 | + assert actual == expected |
| 47 | + |
| 48 | + |
| 49 | +@pytest.fixture |
| 50 | +def broken_fixture(): |
| 51 | + raise ValueError("injected fixture error") |
| 52 | + |
| 53 | + |
| 54 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 55 | +def test_injected_setup_error(broken_fixture): |
| 56 | + pass |
| 57 | + |
| 58 | + |
| 59 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 60 | +@pytest.mark.thread_unsafe(reason="records process-global warnings") |
| 61 | +def test_injected_warning_then_fail(): |
| 62 | + warnings.warn("injected warning: must not become an annotation", UserWarning, stacklevel=1) |
| 63 | + raise AssertionError("injected failure after a warning") |
| 64 | + |
| 65 | + |
| 66 | +@pytest.mark.agent_authored(model="claude-fable-5-1") |
| 67 | +def test_injected_exception_in_helper(): |
| 68 | + def helper(n): |
| 69 | + return 10 // n |
| 70 | + |
| 71 | + assert helper(0) == 1 |
0 commit comments