(pytester: Pytester)
| 125 | |
| 126 | @pytest.mark.filterwarnings("always::UserWarning") |
| 127 | def test_unicode(pytester: Pytester) -> None: |
| 128 | pytester.makepyfile( |
| 129 | """ |
| 130 | import warnings |
| 131 | import pytest |
| 132 | |
| 133 | |
| 134 | @pytest.fixture |
| 135 | def fix(): |
| 136 | warnings.warn("测试") |
| 137 | yield |
| 138 | |
| 139 | def test_func(fix): |
| 140 | pass |
| 141 | """ |
| 142 | ) |
| 143 | result = pytester.runpytest() |
| 144 | result.stdout.fnmatch_lines( |
| 145 | [ |
| 146 | "*== %s ==*" % WARNINGS_SUMMARY_HEADER, |
| 147 | "*test_unicode.py:7: UserWarning: \u6d4b\u8bd5*", |
| 148 | "* 1 passed, 1 warning*", |
| 149 | ] |
| 150 | ) |
| 151 | |
| 152 | |
| 153 | def test_works_with_filterwarnings(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected