Lines Matching full:warnings
299 A convenience wrapper for :func:`warnings.catch_warnings()` that makes it
301 equivalent to calling ``warnings.catch_warnings(record=True)`` with
302 :meth:`warnings.simplefilter` set to ``always`` and with the option to
308 it checks to make sure the warnings are as expected: each specified filter
309 must match at least one of the warnings raised by the enclosed code or the
310 test fails, and if any warnings are raised that do not match any of the
318 In this case all warnings are caught and no errors are raised.
321 returned. The underlying warnings list from
322 :func:`~warnings.catch_warnings` is available via the recorder object's
323 :attr:`warnings` attribute. As a convenience, the attributes of the object
330 warnings list.
337 warnings.warn(UserWarning("Hide me!"))
342 When a test needs to look more deeply into the warnings, rather than
346 warnings.warn("foo")
348 warnings.warn("bar")
350 assert str(w.warnings[0].args[0]) == "foo"
351 assert str(w.warnings[1].args[0]) == "bar"
353 assert len(w.warnings) == 0
355 Here all warnings will be caught, and the test code tests the captured
356 warnings directly.
365 Similar to :func:`check_warnings`, but for Python 3 compatibility warnings.
431 # Get copies of the warnings module for testing without
435 py_warnings = import_fresh_module('warnings', blocked=['_warnings'])
436 c_warnings = import_fresh_module('warnings', fresh=['_warnings'])
478 Class used to record warnings for unit tests. See documentation of