Deprecation warnings scroll past and get ignored until an upgrade breaks the code, so I like to see them fail loudly.
python3 -W error script.py
python3 -W error::DeprecationWarning -m pytest
-W error raises each warning as an exception with a traceback that points at the exact line. The second form limits it to one category, here DeprecationWarning. By default python hides that category outside __main__, and -W overrides this. Pytest accepts the same -W option. Expect third-party packages to trip it, so start with one category or add -W ignore::UserWarning:somepkg.
Further reading: Python command line documentation