Closed dimaqq closed 4 years ago
I am studying a solution. I'll let you know soon if that can be done without breaking anything.
Hi @dimaqq, after months I spent some more time on it and I made it in a simple and effective way. I am solving a few Python 2 issues and it'll be ready to be shipped.
It's as simple as:
@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)
Of course after a pip install mocket==3.9.2
. :package:
https://pypi.org/project/mocket/3.9.2/
It would be awesome if mocket could also mock all kinds of socket errors on demand. I'd love to use this library for negative tests as well as regular tests...