gabrielfalcao / HTTPretty

Intercept HTTP requests at the Python socket level. Fakes the whole socket module
https://httpretty.readthedocs.org
MIT License
2.11k stars 275 forks source link

Support for asyncio/gevent/etc #220

Open BenjamenMeyer opened 9 years ago

BenjamenMeyer commented 9 years ago

It would be great if there was support for monkey patching Python3's asyncio, gevent, and other similar libs as these are becoming more popular. Python3's asyncio should be doable if socketpair was also monkey patched.

rouge8 commented 9 years ago

Per #254, it seems like this might only be a problem with HTTPS, at least with eventlet/gevent. We use HTTPretty through moto, and once we started connecting with is_secure=False, we were able to use gevent + HTTPretty.

BenjamenMeyer commented 9 years ago

Glad you found a solution for gevent, however, asyncio/aiohttp is a different issue. There just isn't any really any project that does to asyncio/aiohttp project what httypretty does to standard sockets.

BenjamenMeyer commented 8 years ago

FWIW, I started my own variant targetted at Python3 and asyncio/aiohttp - https://github.com/TestInABox/aiohttp-mock - still working out some of the details, but the interface should be generally compatible, and help is welcomed.

Note: Updated the URL b/c I moved the projects into their own org.

mindflayer commented 7 years ago

Mocket supports both gevent and asyncio/aiohttp. https://pypi.python.org/pypi/mocket/2.0.0

BenjamenMeyer commented 7 years ago

@mindflayer thanks for the info on that; I'll take a look at it for another project (https://pypi.python.org/pypi/stackinabox) which provides built-in suport for HTTpretty among others.