Can't catch mocked exception because it doesn't inherit BaseException
问题 I'm working on a project that involves connecting to a remote server, waiting for a response, and then performing actions based on that response. We catch a couple of different exceptions, and behave differently depending on which exception is caught. For example: def myMethod(address, timeout=20): try: response = requests.head(address, timeout=timeout) except requests.exceptions.Timeout: # do something special except requests.exceptions.ConnectionError: # do something special except requests