diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2016-06-19 13:00:13 +0200 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2016-08-28 13:30:43 -0600 |
commit | 3c34457ac9e6c11f9197f513013d8ab1ee9d9236 (patch) | |
tree | 08c646973bbac1d693a6f2e5a99fabc6f4aaca27 /doc | |
parent | 90668d0e740e30102fa3d0a1a72b485ebe9d99c3 (diff) | |
download | numpy-3c34457ac9e6c11f9197f513013d8ab1ee9d9236.tar.gz |
ENH,TST: Add new warning suppression/filtering context
This context has a couple of advantages over the typical one, and can
ensure that warnings are cleanly filtered without side effect for
later tests.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/release/1.12.0-notes.rst | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/release/1.12.0-notes.rst b/doc/release/1.12.0-notes.rst index f84511fc1..9a9a50aa8 100644 --- a/doc/release/1.12.0-notes.rst +++ b/doc/release/1.12.0-notes.rst @@ -185,6 +185,23 @@ to ``logspace``, but with start and stop specified directly: ``geomspace(start, stop)`` behaves the same as ``logspace(log10(start), log10(stop))``. +New context manager for testing warnings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A new context manager ``suppress_warnings`` has been added to the testing +utils. This context manager is designed to help reliably test warnings. +Specifically to reliably filter/ignore warnings. Ignoring warnings +by using an "ignore" filter in Python versions before 3.4.x can quickly +result in these (or similar) warnings not being tested reliably. + +The context manager allows to filter (as well as record) warnings similar +to the ``catch_warnings`` context, but allows for easier specificity. +Also printing warnings that have not been filtered or nesting the +context manager will work as expected. Additionally, it is possible +to use the context manager as a decorator which can be useful when +multiple tests give need to hide the same warning. + + Improvements ============ |