--- id: pytest-twisted version: "1.14.3" license: unclear license_treatment: permissive maintenance: active --- # pytest-twisted — A twisted plugin for pytest. License: permissive · Maintenance: active · Downloads: 285.9K/mo ## What it is and what it does pytest-twisted is a pytest plugin that bridges the gap between pytest's synchronous test model and Twisted's asynchronous Deferred-based concurrency. It automatically installs a Twisted reactor before tests run and allows test functions to return Deferred objects, which the plugin waits for rather than treating as test failures. The plugin also provides decorators and fixtures for async/await syntax, inline callbacks, and greenlet access, making it possible to write Twisted tests using pytest's standard fixture and assertion machinery. The plugin supports multiple reactor implementations (default, asyncio, qt5reactor) and integrates with pytest's fixture system, allowing fixtures to also work with async code. It handles the complexity of reactor lifecycle management so developers can focus on testing their Twisted application logic rather than managing event loop setup and teardown. Use it for: - Testing Twisted-based network services and protocol implementations that use Deferred callbacks - Writing async test fixtures that need to wait for Twisted operations before providing test data - Testing Twisted code with async/await syntax using ensureDeferred or async_fixture decorators - Integrating Twisted application tests into a pytest-based test suite alongside synchronous tests - Testing libraries that depend on greenlets and need access to the reactor greenlet context ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that enables testing of Twisted-based asynchronous code by allowing test functions to return Deferred objects and waiting for their completion. Yes, if you are testing Twisted code. The plugin is actively maintained, has no known vulnerabilities, and low install friction. It solves a real problem—running Twisted's asynchronous code within pytest's synchronous test framework—and is the standard tool for this task. Install it if Twisted is part of your project; skip it otherwise. ## Install pip install pytest-twisted uv add pytest-twisted poetry add pytest-twisted ## Installing pytest-twisted Before you install: Low install friction with a pure-Python wheel distribution. Actively maintained with recent commits and stable status; last release was 703 days ago but the repository shows ongoing activity. License in practice: Permissive license treatment means you can use this plugin in commercial and proprietary projects without significant legal constraints. Quickstart: pip install pytest-twisted # In conftest.py or test file: import pytest_twisted from twisted.internet import defer @pytest_twisted.inlineCallbacks def test_deferred_operation(): result = yield defer.succeed(42) assert result == 42 Requires Twisted to be installed separately; on Windows with Python 3.8+, asyncio reactor requires explicit selector loop configuration as documented in the package description. Verify before relying: - Whether Python 2.7 support remains practically tested or is maintained for compatibility only - Current state of Windows + Python 3.8+ asyncio reactor compatibility beyond the documented workaround ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 285.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest twisted testing, test twisted deferred, async twisted tests, pytest async reactor, twisted framework testing, deferred test plugin, pytest twisted integration, twisted-testing, async-reactor, deferred-support [View on SkillFed](https://skillfed.io/packages/pytest-twisted) · [View on PyPI](https://pypi.org/project/pytest-twisted/)