{"library":"pytest-twisted","title":"pytest-twisted","description":"pytest-twisted is a plugin for the pytest testing framework that facilitates testing code built with the Twisted asynchronous networking framework. It allows pytest test functions to return Twisted Deferred objects, ensuring that tests wait for asynchronous operations to complete, and manages the Twisted reactor lifecycle within the test suite. The library is actively maintained, with its current version being 1.14.3.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install pytest-twisted"],"cli":null},"imports":["from pytest_twisted import inlineCallbacks","from pytest_twisted import ensureDeferred","import pytest_twisted"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\nfrom twisted.internet.defer import Deferred\nfrom pytest_twisted import inlineCallbacks\n\n@inlineCallbacks\ndef test_deferred_returns_value():\n    d = Deferred()\n    d.callback('hello')\n    result = yield d\n    assert result == 'hello'\n\n@pytest.mark.reactor_default # Or specify --reactor=asyncio in pytest command\n@inlineCallbacks\ndef test_reactor_is_running():\n    from twisted.internet import reactor\n    assert reactor.running\n\n# To run this, save as test_example.py and run: pytest test_example.py","lang":"python","description":"This quickstart demonstrates how to write a basic test using `pytest-twisted`. It shows a test function decorated with `pytest_twisted.inlineCallbacks` that yields a Twisted Deferred and asserts its result. A second example checks if the Twisted reactor is running within the test context. You can specify a reactor type using `--reactor` (e.g., `--reactor=asyncio`) when running pytest.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"1.14.3","pypi_latest":"1.14.3","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3.1,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":"34M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"39.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":"37M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"31.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.8,"import_time_s":null,"mem_mb":null,"disk_size":"28M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"30.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":"28M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"34.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pytest-twisted","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.6,"import_time_s":null,"mem_mb":null,"disk_size":"33M"}]}}