samedi 9 juillet 2016

How can certain warnings be ignored while others turned to exceptions from Python command line?

How can execute Python from the command line and ignore certain warings (such as DeprecationWarning) while turning the rest into exceptions?

Can the -W option be used multiple times to do this?

The specific problem I am facing is that I am running pytest/pytest-cov inside of tox/virtualenv and because virtualenv uses an outdated site.py module, a DeprecationWarning is thrown when I run with -Werror before I gain access in my code to catch it. I'd like to minimize the effect to my testing by at least ignoring only this warning, and turn the others (ImportWarning, etc) into exceptions so I can detect and handle those in my own code.

Aucun commentaire:

Enregistrer un commentaire