warnings.py 831 B

12345678910111213141516171819202122232425262728293031
  1. # testing/warnings.py
  2. # Copyright (C) 2005-2021 the SQLAlchemy authors and contributors
  3. # <see AUTHORS file>
  4. #
  5. # This module is part of SQLAlchemy and is released under
  6. # the MIT License: http://www.opensource.org/licenses/mit-license.php
  7. import warnings
  8. from sqlalchemy import exc as sa_exc
  9. def setup_filters():
  10. """Set global warning behavior for the test suite."""
  11. warnings.resetwarnings()
  12. warnings.filterwarnings("error", category=sa_exc.SADeprecationWarning)
  13. warnings.filterwarnings("error", category=sa_exc.SAWarning)
  14. # some selected deprecations...
  15. warnings.filterwarnings("error", category=DeprecationWarning)
  16. try:
  17. import pytest
  18. except ImportError:
  19. pass
  20. else:
  21. warnings.filterwarnings(
  22. "once", category=pytest.PytestDeprecationWarning
  23. )