The essence of the -W error flag is that if pytest encounters a worning, it throws a UserWarning exception, i.e. all the code that goes in the test after vorning will not be executed, the test will fall.
Constructs except Exception: not recommended by PEP8. Here is a vivid example of yours. The logic of your test will be broken, as pytets will throw a UserWarning exception, your except will UserWarning it and the execution will go to processErrors() . And, perhaps, some unnecessary actions will be performed. And if you run without the -W error flag, then the test will go the other way, without processErrors() .
Those. The logic of the test will depend on what auxiliary parameters it run. As for me, this is ideologically wrong.
I recommend rewriting the try:... except:... constructions try:... except:... with an explicit indication of what exceptions you expect.
-W errordoes not write. Instead, the Vorning throws an exception. If there is something like `` `try: foo (), warn () except Exception: processException ()` `, then the Vorning will be treated as if a normal exception has occurred and the flow will go further, and the outsider will be unaware of that that the Vorning was, since nothing is written in the stderr. To cover except Warning all tras does not suit me. I believe that there is still something appropriate in api warning / paytest - NikBondUserWarning: api v1, should use functions from v2- suit