I\'m trying to write a Unit Test for a piece of python code that raises a warning via logger.warn(\'...\') under certain conditions. How do I assert that this w
In your unit test setup, add a logging handler which buffers records, and remove it during teardown. You can use as a basis a couple of utility classes, TestHandler and Matcher, which are part of the Python test infrastructure. (The link is to Python's default branch, but the classes should be usable in other Python versions). For information on how to use these classes, see this post.