|
| 1 | +import pytest |
| 2 | + |
| 3 | + |
| 4 | +@pytest.fixture |
| 5 | +def failed_fixture(): |
| 6 | + assert False |
| 7 | + |
| 8 | + |
| 9 | +def test_failed_fixture(failed_fixture): |
| 10 | + """ |
| 11 | + >>> allure_report = getfixture('allure_report') |
| 12 | + >>> assert_that(allure_report, |
| 13 | + ... has_test_case('test_failed_fixture', |
| 14 | + ... with_status('failed'), |
| 15 | + ... has_status_details(with_message_contains("AssertionError"), |
| 16 | + ... with_trace_contains("def failed_fixture():") |
| 17 | + ... ), |
| 18 | + ... has_container(allure_report, |
| 19 | + ... has_before('failed_fixture', |
| 20 | + ... with_status('failed'), |
| 21 | + ... has_status_details(with_message_contains("AssertionError"), |
| 22 | + ... with_trace_contains("failed_fixture") |
| 23 | + ... ), |
| 24 | + ... ), |
| 25 | + ... ) |
| 26 | + ... ) |
| 27 | + ... ) |
| 28 | + """ |
| 29 | + pass |
| 30 | + |
| 31 | + |
| 32 | +@pytest.fixture |
| 33 | +def broken_fixture(): |
| 34 | + raise IndexError |
| 35 | + |
| 36 | + |
| 37 | +def test_broken_fixture(broken_fixture): |
| 38 | + """ |
| 39 | + >>> allure_report = getfixture('allure_report') |
| 40 | + >>> assert_that(allure_report, |
| 41 | + ... has_test_case('test_broken_fixture', |
| 42 | + ... with_status('broken'), |
| 43 | + ... has_status_details(with_message_contains("IndexError"), |
| 44 | + ... with_trace_contains("def broken_fixture():") |
| 45 | + ... ), |
| 46 | + ... has_container(allure_report, |
| 47 | + ... has_before('broken_fixture', |
| 48 | + ... with_status('broken'), |
| 49 | + ... has_status_details(with_message_contains("IndexError"), |
| 50 | + ... with_trace_contains("broken_fixture") |
| 51 | + ... ), |
| 52 | + ... ), |
| 53 | + ... ) |
| 54 | + ... ) |
| 55 | + ... ) |
| 56 | + """ |
| 57 | + pass |
| 58 | + |
| 59 | + |
| 60 | +@pytest.fixture |
| 61 | +def skip_fixture(): |
| 62 | + pytest.skip() |
| 63 | + |
| 64 | + |
| 65 | +def test_skip_fixture(skip_fixture): |
| 66 | + """ |
| 67 | + >>> allure_report = getfixture('allure_report') |
| 68 | + >>> assert_that(allure_report, |
| 69 | + ... has_test_case('test_skip_fixture', |
| 70 | + ... with_status('skipped'), |
| 71 | + ... has_status_details(with_message_contains("Skipped: <Skipped instance>")), |
| 72 | + ... has_container(allure_report, |
| 73 | + ... has_before('skip_fixture', |
| 74 | + ... with_status('skipped'), |
| 75 | + ... has_status_details(with_message_contains("Skipped: <Skipped instance>"), |
| 76 | + ... with_trace_contains("skip_fixture") |
| 77 | + ... ), |
| 78 | + ... ), |
| 79 | + ... ) |
| 80 | + ... ) |
| 81 | + ... ) |
| 82 | + """ |
| 83 | + |
| 84 | + |
| 85 | +@pytest.fixture |
| 86 | +def pytest_fail_fixture(): |
| 87 | + pytest.fail() |
| 88 | + |
| 89 | + |
| 90 | +def test_pytest_fail_fixture(pytest_fail_fixture): |
| 91 | + """ |
| 92 | + >>> allure_report = getfixture('allure_report') |
| 93 | + >>> assert_that(allure_report, |
| 94 | + ... has_test_case('test_pytest_fail_fixture', |
| 95 | + ... with_status('failed'), |
| 96 | + ... has_status_details(with_message_contains("Failed: <Failed instance>"), |
| 97 | + ... with_trace_contains("def pytest_fail_fixture():") |
| 98 | + ... ), |
| 99 | + ... has_container(allure_report, |
| 100 | + ... has_before('pytest_fail_fixture', |
| 101 | + ... with_status('failed'), |
| 102 | + ... has_status_details(with_message_contains("Failed: <Failed instance>"), |
| 103 | + ... with_trace_contains("pytest_fail_fixture") |
| 104 | + ... ), |
| 105 | + ... ), |
| 106 | + ... ) |
| 107 | + ... ) |
| 108 | + ... ) |
| 109 | + """ |
| 110 | + pass |
| 111 | + |
| 112 | + |
| 113 | +@pytest.fixture |
| 114 | +def pytest_fail_with_reason_fixture(): |
| 115 | + pytest.fail("Fail message") |
| 116 | + |
| 117 | + |
| 118 | +def test_pytest_fail_with_reason_fixture(pytest_fail_with_reason_fixture): |
| 119 | + """ |
| 120 | + >>> allure_report = getfixture('allure_report') |
| 121 | + >>> assert_that(allure_report, |
| 122 | + ... has_test_case('test_pytest_fail_with_reason_fixture', |
| 123 | + ... with_status('failed'), |
| 124 | + ... has_status_details(with_message_contains("Fail message"), |
| 125 | + ... with_trace_contains("def pytest_fail_with_reason_fixture():") |
| 126 | + ... ), |
| 127 | + ... has_container(allure_report, |
| 128 | + ... has_before('pytest_fail_with_reason_fixture', |
| 129 | + ... with_status('failed'), |
| 130 | + ... has_status_details(with_message_contains("Fail message"), |
| 131 | + ... with_trace_contains("pytest_fail_with_reason_fixture") |
| 132 | + ... ), |
| 133 | + ... ), |
| 134 | + ... ) |
| 135 | + ... ) |
| 136 | + ... ) |
| 137 | + """ |
| 138 | + pass |
| 139 | + |
| 140 | + |
0 commit comments