Skip to content

Mocket can fake socket errors

Choose a tag to compare

@mindflayer mindflayer released this 11 Oct 11:04
adefc72

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)