MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_non_string_warning_argument

Function test_non_string_warning_argument

testing/test_warnings.py:211–223  ·  view source on GitHub ↗

Non-str argument passed to warning breaks pytest (#2956)

(pytester: Pytester)

Source from the content-addressed store, hash-verified

209
210
211def test_non_string_warning_argument(pytester: Pytester) -> None:
212 """Non-str argument passed to warning breaks pytest (#2956)"""
213 pytester.makepyfile(
214 """\
215 import warnings
216 import pytest
217
218 def test():
219 warnings.warn(UserWarning(1, 'foo'))
220 """
221 )
222 result = pytester.runpytest("-W", "always::UserWarning")
223 result.stdout.fnmatch_lines(["*= 1 passed, 1 warning in *"])
224
225
226def test_filterwarnings_mark_registration(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected