So this is a bit of a strange question, but it might be interesting!
I need to somehow reliably throw an exception in python. I would prefer it to be caused by a person, but I also want to inject something into my code, which will always be the cause of the exception. (I have configured exception handling and would like to test it)
I look around, and some ideas seem to be dividing by zero, or something in this direction will always be the cause of the exception. Is there a better way? The most ideal would be to simulate the loss of an Internet connection while the program is running ... any ideas would be great!
Good luck
source
share