Skip to main content

Termtrace for Python

Record and drive terminal programs from Python.

tests PyPI Python downloads license

This package is the Python SDK for Termtrace, a flight recorder for terminal programs. Start a program in a recorded terminal, wait for text on its screen, and send it keys.

  • Screen waits: Block until the screen shows the text you expect, with a timeout.
  • Test fixture: In pytest, termtrace_session records the programs a test starts and keeps the recording when the test fails.
  • Asynchronous API: termtrace.aio offers the same calls for asyncio code.
  • Nothing else to install: The wheel bundles the termtrace binary.

Installation

uv add termtrace

Requires Python 3.10 or newer on Linux with glibc 2.39 or newer.

Examples

Drive a program

import termtrace

with termtrace.Termtrace().record(["python3"]) as rec:
    rec.screen().wait_for_text(">>>", timeout_secs=5)
    rec.actions().send_text("print(6 * 7)").send_key("enter").until_screen("42").run()
    print(rec.screen().frame().text)

Test with pytest

def test_python_answers(termtrace_session):
    rec = termtrace_session(["python3"])
    rec.screen().wait_for_text(">>>", timeout_secs=5)
    rec.actions().send_text("print(6 * 7)").send_key("enter").until_screen("42").run()
    assert "42" in rec.screen().frame().text

Use asyncio

import asyncio

from termtrace.aio import AsyncTermtrace


async def main():
    async with await AsyncTermtrace().record(["python3"]) as rec:
        await rec.screen().wait_for_text(">>>", timeout_secs=5)
        await rec.actions().send_text("print(6 * 7)").send_key("enter").until_screen("42").run()
        print((await rec.screen().frame()).text)


asyncio.run(main())

License

MIT

Metadata

Release files for termtrace 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for termtrace 0.1.1
File Interpreter ABI Platform Actions
termtrace-0.1.1-cp310-abi3-manylinux_2_39_x86_64.whl CPython 3.10 abi3 Linux glibc 2.39+ x86-64 Details for termtrace-0.1.1-cp310-abi3-manylinux_2_39_x86_64.whl
termtrace-0.1.1-cp310-abi3-manylinux_2_39_aarch64.whl CPython 3.10 abi3 Linux glibc 2.39+ ARM64 Details for termtrace-0.1.1-cp310-abi3-manylinux_2_39_aarch64.whl

Total release size: 55.6 MB

Release files / termtrace-0.1.1-cp310-abi3-manylinux_2_39_x86_64.whl

Download URL termtrace-0.1.1-cp310-abi3-manylinux_2_39_x86_64.whl
Size 28.5 MB
Tags CPython 3.10 Linux glibc 2.39+ x86-64 abi3
SHA-256 checksum
How to use checksums
5b8ef764297d2e84ff824409761cc77ec51950cfb8f83b4a3a125dd0bbbcabe6
BLAKE2b-256 checksum
How to use checksums
f69bad824f33bce5401916062c4d9e9dbfdeb4537200ba9c53e6b470647c9bea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / termtrace-0.1.1-cp310-abi3-manylinux_2_39_aarch64.whl

Download URL termtrace-0.1.1-cp310-abi3-manylinux_2_39_aarch64.whl
Size 27.1 MB
Tags CPython 3.10 Linux glibc 2.39+ ARM64 abi3
SHA-256 checksum
How to use checksums
71eeafdeb61eb658a5d2e3126f96ee8021c0cc1cbfaaaaad28dc35cf1ae4e0db
BLAKE2b-256 checksum
How to use checksums
35010b2b893f261e47e545a7482bc2445460566ca1d5b76c1b2a0a35b4371189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for termtrace 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page