skillfed

pytest-tornado

A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.

pytest-tornado v0.8.1 378.3K downloads/30d#7,119 on PyPI118
Permissive license Apache License, Version 2.0 Abandoned released

What it is and what it does

pytest-tornado is a pytest plugin that bridges the gap between pytest's synchronous test model and Tornado's asynchronous event loop. It provides fixtures (io_loop, http_server, http_client, base_url, http_port) and a gen_test marker that let you write tests for Tornado web applications using both generator-based coroutines (yield) and modern async/await syntax. The plugin manages the IOLoop lifecycle per test, spins up temporary HTTP/HTTPS servers, and handles timeouts automatically.

You define a Tornado application as a pytest fixture, then write test functions marked with @pytest.mark.gen_test that can yield or await HTTP requests. The plugin injects fixtures like http_client and base_url so your test can make requests to the test server and verify responses. It also supports HTTPS testing when you provide an ssl_options fixture.

Use it for:

  • Test Tornado RequestHandler classes by making HTTP requests through http_client and verifying response codes and body content.
  • Write async integration tests that exercise both client and server concurrently using run_sync=False to keep them on the same IOLoop.
  • Validate HTTPS endpoints by providing ssl_options and using https_server and https_client fixtures.
  • Test WebSocket handlers and other async Tornado features that require a running IOLoop and real HTTP server.
  • Migrate legacy Tornado test suites from older test runners to pytest while preserving async test patterns.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that provides fixtures and markers to test asynchronous Tornado web applications, handling async/await and generator-based coroutine tests with built-in HTTP server and client support.

Yes, if you are actively testing a Tornado application and want pytest integration—it eliminates boilerplate for IOLoop and server setup. However, be cautious: the project is abandoned (last release June 2020, no commits since). It works for current Tornado and pytest versions, but you should monitor compatibility and be prepared to fork or switch if breaking changes occur in either dependency. No security vulnerabilities are known.

Install

pytest-tornado on PyPI

pip

pip install pytest-tornado

uv

uv add pytest-tornado

poetry

poetry add pytest-tornado

Installing pytest-tornado

Before you install

Low install friction with a pure-Python wheel. However, the package is abandoned—last release was 2020-06-17 and no commits since then. It remains marked Production/Stable and has seen no security issues, but you should expect no maintenance for compatibility with newer pytest or Tornado versions.

License in practice

Licensed under Apache License 2.0 (permissive), so you can use, modify, and distribute it freely with minimal restrictions. No license-based barriers to adoption.

Quickstart

pip install pytest-tornado

import pytest
import tornado.web

@pytest.fixture
def app():
    return tornado.web.Application([(r"/", MyHandler)])

@pytest.mark.gen_test
def test_example(http_client, base_url):
    response = yield http_client.fetch(base_url)
    assert response.code == 200

Requires pytest and tornado to be installed; gen_test tests default to a 5-second timeout (configurable via ASYNC_TEST_TIMEOUT environment variable or marker argument).

Verify before relying

  • Compatibility with current pytest and Tornado major versions (last tested 2020-06-17)
  • Whether async/await syntax support is fully stable across all test patterns
  • HTTPS testing prerequisites and certificate handling details

Package facts

License Apache License, Version 2.0 (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 3 — pytest, tornado, setuptools
Maintenance abandoned — 2,249 days since the last release
Last repo commit
First released
Downloads 378,257/month — #7,119 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_tornado-0.8.1-py2.py3-none-any.whl

Keywords: pytest, py.test, tornado, async, asynchronous, testing, unit, tests, plugin

Development Status :: 5 - Production/StableEnvironment :: PluginsIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software DevelopmentTopic :: Software Development :: Testing

Tags

pytest tornado testingasync tornado test fixturestornado web app testingpytest async coroutine markertornado http server testingpytest gen_test decoratortornado ioloop pytest plugin
tornado-testingasync-fixturespytest-plugin

More Software Development packages