{"library":"pytest-eventlet","title":"pytest-eventlet","description":"pytest-eventlet is a pytest plugin that automatically applies the eventlet monkey-patch to your test suite. It simplifies testing eventlet-dependent code by ensuring the environment is correctly configured. The current version is 1.0.0, and as an initial release, its cadence is currently low but stable.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pytest-eventlet eventlet"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import socket\nimport eventlet\nimport pytest\nimport subprocess\nimport sys\n\n# Save this as test_eventlet_patch.py\ndef test_socket_is_monkey_patched():\n    assert eventlet.patcher.is_monkey_patched('socket'), \"Socket module was not monkey-patched by eventlet!\"\n\n# To run this, create a temporary file and invoke pytest\n# Example of how to run this from a script:\n# with open('test_eventlet_patch.py', 'w') as f:\n#     f.write('''\n# import socket\n# import eventlet\n# def test_socket_is_monkey_patched():\n#     assert eventlet.patcher.is_monkey_patched('socket'), \"Socket module was not monkey-patched by eventlet!\"\n#     ''')\n# result = subprocess.run([sys.executable, '-m', 'pytest', 'test_eventlet_patch.py'], capture_output=True, text=True)\n# print(result.stdout)\n# print(result.stderr)\n# assert \"1 passed\" in result.stdout\n# assert \"Socket module was not monkey-patched\" not in result.stdout # Ensure it passed\n","lang":"python","description":"Create a file named `test_eventlet_patch.py`. With `pytest-eventlet` and `eventlet` installed, simply running `pytest` will automatically apply the monkey-patch. This quickstart test verifies that the `socket` module has indeed been patched by `eventlet`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}