Python 2.7 Unit test: Assert logger warning thrown

Viewed 5021

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 warning has been logged? I noticed that assertLogged is not available until at least Python 3.4, unfortunately I am in 2.7.

2 Answers
Related