Apathetic Python Testing π§ͺ
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] This project is largely AI-written and minimally polished. I rely on it, but I havenβt reviewed every detail. Expect rough edges. Thoughtful issue reports are appreciated.
Features
- π Logging Fixtures β Isolated logging state, TEST level debugging, level change assertions
- π― Safe Patching β
patch_everywherefor reliable mocking in package, stitched, and zipapp modes - π Runtime Testing β
runtime_swapto 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
Quick Example
from apathetic_testing import patch_everywhere
from apathetic_testing.logging import (
isolated_logging,
logging_test_level,
logging_level_testing,
)
from unittest.mock import Mock
# Test with isolated logging
def test_app_logging(isolated_logging):
isolated_logging.set_root_level("DEBUG")
my_app.run()
# State automatically reset after test
# Debug with TEST level (all logs visible)
def test_app_with_debugging(logging_test_level):
my_app.run() # All DEBUG and TRACE logs visible
# Test log level changes (e.g., --log-level flag)
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 that works in all runtime modes
def test_with_patching():
with patch_everywhere("module.function", Mock(return_value=42)):
result = module.function()
assert result == 42
Requirements
- Python 3.10+
No other dependencies required β this library uses only Pythonβs standard library.
Installation
Install via poetry or pip:
# Using poetry
poetry add apathetic-testing
# Using pip
pip install apathetic-testing
Documentation
- Usage Guide β Integration patterns and best practices
- API Reference β Complete API documentation
- Pytest Plugins β Built-in plugins documentation
- Contributing β How to contribute
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.
Resources
- π Roadmap
- π Release Notes
- π Issue Tracker
- π¬ Discord