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.2

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.2
File Interpreter ABI Platform Actions
termtrace-0.1.2-cp310-abi3-manylinux_2_39_x86_64.whl CPython 3.10 abi3 Linux glibc 2.39+ x86-64 Details for termtrace-0.1.2-cp310-abi3-manylinux_2_39_x86_64.whl
termtrace-0.1.2-cp310-abi3-manylinux_2_39_aarch64.whl CPython 3.10 abi3 Linux glibc 2.39+ ARM64 Details for termtrace-0.1.2-cp310-abi3-manylinux_2_39_aarch64.whl

Total release size: 55.6 MB

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

Download URL termtrace-0.1.2-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
b56b13d41ab2ecbc4c3ed90ae33ecbdd2bdf4378abe5e17d942f85563cb2dbfa
BLAKE2b-256 checksum
How to use checksums
4d6397f572e86aa089f641eeba77b696363346a713e54d6743c606268fda152b
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.2-cp310-abi3-manylinux_2_39_aarch64.whl

Download URL termtrace-0.1.2-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
c09f646cb5f530d0a4bcf91118162670f3e60f3d2135ae84bc99a622bebdce86
BLAKE2b-256 checksum
How to use checksums
876aff9c55fbfd9eeb48a089c362c20f8071aa05e88f45aebcba93924361ae85
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.2

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