Given this code:
def main(b):
try:
a = 2 / b
return "Hello World"
except Exception:
return "Exception"
How to test the path which handles the exception using patching?
Would it possible to make a = 2 / b
as a valid target to patch?
Similar questions:
How to use Python Mock to raise an exception - but with Errno set to a given value
Mocking - How do I raise exception on the caller?
Mocking a function to raise an Exception to test an except block