Skip to main content

dyno-lab

Portfolio-wide test bench utilities for unified test building, expansion, and refactoring.

dyno-lab provides reusable fixtures, mocks, assertions, and smoke-test scaffolding drawn from patterns across every tested repository in the portfolio.

Overview

Module Purpose
dyno_lab.base DynoTestCase — unittest.TestCase with extra assertions
dyno_lab.proc Subprocess mocking (ProcessRecorder, SubprocessPatch)
dyno_lab.env Environment patching (EnvPatch, patched_env)
dyno_lab.fs Filesystem fixtures (TempWorkdir, make_tree)
dyno_lab.cli CLI capture (capture_cli, CLITestMixin, CliResult)
dyno_lab.http HTTP session mocking (SequenceSession, StaticSession, RaisingSession)
dyno_lab.delivery Leased at-least-once delivery adapter conformance helper
dyno_lab.schema Schema/contract helpers (assert_parity, assert_row_width)
dyno_lab.module Dynamic module loading (load_module_by_path)
dyno_lab.markers Shared pytest markers (unit, integration, smoke, parity, slow, external)
dyno_lab.fixtures Pytest fixtures (dyno_tmp, dyno_env, dyno_proc, dyno_cli)
dyno_lab.smoke Smoke test scaffolding (SmokeTest, SmokeRunner, SmokeResult)

Prerequisites

  • Python 3.10 or later
  • pytest (for the fixture and marker integrations)

Installation

# From the portfolio root — install in editable mode into your target repo's venv
pip install -e ./util-repos/dyno-lab

Or as a local path dependency in pyproject.toml:

[project.optional-dependencies]
dev = ["dyno-lab @ file:///path/to/util-repos/dyno-lab"]

Quick Start

Subprocess mocking

from dyno_lab.proc import ProcessRecorder, SubprocessPatch, build_completed_process

recorder = ProcessRecorder(responses=[
    build_completed_process(stdout="VPN Connected"),
])
with SubprocessPatch(recorder, target="mymodule.subprocess.run"):
    result = client.connect()

assert recorder.commands()[0] == ("nordvpn", "connect", "United States")

Environment patching

from dyno_lab.env import EnvPatch, env_defaults

DEFAULTS = env_defaults(
    MY_APP_DB_PATH="/tmp/test.db",
    MY_APP_PASSWORD="test-pass",
)

with EnvPatch(DEFAULTS):
    result = my_function()

Filesystem fixtures

from dyno_lab.fs import TempWorkdir

with TempWorkdir() as wd:
    wd.populate({
        "config.toml": "[project]\nname = 'demo'\n",
        "src/pkg/__init__.py": "",
    })
    wd.assert_exists("config.toml")
    wd.assert_contains("config.toml", "demo")

CLI capture

from dyno_lab.cli import capture_cli

code, out, err = capture_cli(main, ["connect"])
assert code == 0
assert "Connected" in out

HTTP session mocking

from dyno_lab.http import SequenceSession
from unittest.mock import patch

session = SequenceSession(['{"results": []}', '<html>fallback</html>'])
with patch("myapp.get_session", return_value=session):
    items = fetch_items()

assert session.call_count == 2

Schema / provider parity

from dyno_lab.schema import assert_parity

assert_parity(
    [bank_module, cred_module, invest_module],
    factory=lambda m: m.StatementRecord(**base_kwargs()),
    extractor=lambda r: len(r.as_row()),
    attribute="row width",
)

Smoke tests

from dyno_lab.smoke import SmokeTest, SmokeResult, SmokeRunner

class MyServiceSmoke(SmokeTest):
    name = "my-service-ping"

    def run(self) -> SmokeResult:
        try:
            response = ping_service()
            return SmokeResult.ok(self.name, f"latency={response.latency_ms}ms")
        except Exception as exc:
            return SmokeResult.failed(self.name, str(exc))

runner = SmokeRunner([MyServiceSmoke()])
summary = runner.run_all()
summary.raise_if_failed()

Leased delivery conformance

For an offline queue backed by a durable lease store, expose four small test callbacks and exercise the common lifecycle without coupling Dyno Lab to the provider or database:

from dyno_lab.delivery import LeasedDeliveryDriver, assert_leased_delivery_contract

exercise = assert_leased_delivery_contract(
    LeasedDeliveryDriver(
        enqueue=queue.enqueue,
        claim=queue.claim,
        complete=queue.complete,
        fail=queue.fail,
    ),
    {"message": "retry safely"},
)
assert exercise.first_lease_token != exercise.retry_lease_token

The helper verifies at-least-once queue mechanics only. Provider timeouts can still yield duplicate user-visible delivery; keep exactly-once behavior in an explicit caller or provider idempotency key.

Pytest fixtures

In your project's conftest.py:

pytest_plugins = ["dyno_lab.fixtures"]

Then in tests:

def test_something(dyno_tmp, dyno_env, dyno_proc):
    dyno_tmp.write("config.json", '{"key": "val"}')
    with dyno_env(MY_VAR="test"):
        recorder = dyno_proc(default_stdout="ok")
        ...

Pytest markers

# conftest.py
from dyno_lab.markers import register_markers

def pytest_configure(config):
    register_markers(config)

Then decorate tests:

import pytest

@pytest.mark.unit
def test_fast_thing(): ...

@pytest.mark.integration
def test_with_filesystem(): ...

@pytest.mark.smoke
def test_service_health(): ...

@pytest.mark.parity
def test_all_providers_match(): ...

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Run tests
pytest -q

# Run pre-commit
pre-commit run --all-files

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.

Metadata

Release files for dyno-lab 0.3.0

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

Source distribution (sdist)

Source distribution for dyno-lab 0.3.0
File Size Uploaded Provenance Actions
dyno_lab-0.3.0.tar.gz 39.3 kB With provenance Details for dyno_lab-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dyno-lab 0.3.0
File Interpreter ABI Platform Actions
dyno_lab-0.3.0-py3-none-any.whl Python 3 none any Details for dyno_lab-0.3.0-py3-none-any.whl

Total release size: 72.0 kB

Release files / dyno_lab-0.3.0.tar.gz

Download URL dyno_lab-0.3.0.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b6aa6a568a27c4b43419bdfc1c27182839992d5e19c1b092a976c72134b2b30d
BLAKE2b-256 checksum
How to use checksums
42ee5e01e0a33b86d52596575fbc3ead96bdf6e5b83636792c060f3ad9e08cef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / dyno_lab-0.3.0-py3-none-any.whl

Download URL dyno_lab-0.3.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dab91f5fac467ea05f90e378b9866eb9cea8193da6ea2d26686ac72e9cc49c92
BLAKE2b-256 checksum
How to use checksums
84055f6ed085ad90bb0bdf516fba5ea6cbda214f275f05e726bc5fc432d252ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for dyno-lab 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dyno_lab-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

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