pytest_recwarn plugin

helpers for asserting deprecation and other warnings.

Example usage

You can use the recwarn funcarg to track warnings within a test function:

You can also call a global helper for checking taht a certain function call yields a Deprecation warning:

the 'recwarn' test function argument

Return a WarningsRecorder instance that provides these methods:

  • pop(category=None): return last warning matching the category.
  • clear(): clear list of warnings

Start improving this plugin in 30 seconds

  1. Download pytest_recwarn.py plugin source code
  2. put it somewhere as pytest_recwarn.py into your import path
  3. a subsequent py.test run will use your local version

Checkout customize, other plugins or get in contact.