Mocket can fake socket errors
https://github.com/mindflayer/python-mocket#example-of-how-to-fake-a-socket-errors
@mocketize
def test_raise_exception(self):
url = "http://github.com/fluidicon.png"
Entry.single_register(Entry.GET, url, exception=socket.error())
with self.assertRaises(requests.exceptions.ConnectionError):
requests.get(url)