Skip to main content

Runtime-aware pytest extensions.

Project description

Apathetic Python Testing 🧪

CI License: MIT-a-NOAI Discord

📘 Roadmap · 📝 Release Notes

Runtime-aware pytest extensions.
When you need just a bit more.

Apathetic Python Testing provides a focused collection of pytest fixtures and utilities designed for Apathetic Tools projects. It helps you test CLI applications, logging behavior, and code that ships as stitched scripts or zipapps.

Some ways to generate stitched scripts are serger; and for zipapps: zipbundler or stdlib's zipapp.

[!NOTE] Heads up: the AI cooked dinner. It's edible, but watch your step.
Detailed bug reports welcome.

Quick Start

from apathetic_testing import patch_everywhere, runtime_swap
from apathetic_testing.logging import (
    isolated_logging,
    logging_test_level,
    logging_level_testing,
)

# Test log level isolation
def test_app_logging(isolated_logging):
    # Each test gets fresh logging state
    isolated_logging.set_root_level("DEBUG")
    my_app.run()

# Debug with maximum verbosity
def test_app_with_debugging(logging_test_level):
    # Root logger at TEST level - all logs visible
    my_app.run()

# Test log level changes
def test_cli_debug_flag(logging_level_testing):
    cli.main(["--log-level", "debug"])
    logging_level_testing.assert_level_changed_from("ERROR", to="DEBUG")

# Safe patching in all runtime modes
from unittest.mock import Mock
with patch_everywhere("module.function", Mock(return_value=42)):
    result = module.function()

# Test stitched/zipapp builds
def test_in_stitched_mode(runtime_swap):
    # Automatically swaps to stitched mode if available
    import my_package
    my_package.function()

Installation

# Using poetry
poetry add apathetic-testing

# Using pip
pip install apathetic-testing

Documentation

📚 Full Documentation →

For installation guides, API reference, examples, and more, visit our documentation website.

Features

  • 🔍 Logging Fixtures — Isolated logging state, TEST level debugging, level change assertions
  • 🎯 Safe Patchingpatch_everywhere for reliable mocking in package, stitched, and zipapp modes
  • 🔄 Runtime Testingruntime_swap to test stitched scripts and zipapp builds
  • 🪶 Lightweight — Minimal dependencies (only apathetic-logging)
  • 🧪 CLI-Focused — Designed for testing command-line applications and config-driven tools
  • 🔧 Helper Utilities — Mock superclass detection, assertion helpers, and more

⚖️ License

You're free to use, copy, and modify the library under the standard MIT terms.
The additional rider simply requests that this project not be used to train or fine-tune AI/ML systems until the author deems fair compensation frameworks exist.
Normal use, packaging, and redistribution for human developers are unaffected.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apathetic_testing-0.2.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apathetic_testing-0.2.0-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file apathetic_testing-0.2.0.tar.gz.

File metadata

  • Download URL: apathetic_testing-0.2.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for apathetic_testing-0.2.0.tar.gz
Algorithm Hash digest
SHA256 de65df92d366631b0f2ca3ce3b1ca3d4f29e1af76a69402b4e4e840c3e8cdcb5
MD5 282ac9d1d9e1ca79b1a676ba537b96bc
BLAKE2b-256 0185e06d70d94dd40c4e42850280bde413dd101d4ae4aa99cfce36cffed4f844

See more details on using hashes here.

Provenance

The following attestation bundles were made for apathetic_testing-0.2.0.tar.gz:

Publisher: publish_pypi.yml on apathetic-tools/python-testing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apathetic_testing-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for apathetic_testing-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e76a551296b87c27844a2ee219706b92eaa5c5f3183b490d45ae536d88363e
MD5 08a6fd14259d957cc28353b8a2dc16b0
BLAKE2b-256 df0e30881877915fb6446f8e0777d56a1b51b6fe69b57ceaf5586fbcc366c850

See more details on using hashes here.

Provenance

The following attestation bundles were made for apathetic_testing-0.2.0-py3-none-any.whl:

Publisher: publish_pypi.yml on apathetic-tools/python-testing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page