--- id: expecttest version: "0.3.0" license: MIT license_treatment: permissive maintenance: aging --- # expecttest License: permissive · Maintenance: aging · Downloads: 2.3M/mo ## What it is and what it does expecttest is a testing library that implements golden tests with inline expectations—a pattern where you write tests with blank expected-output placeholders, run them to capture actual output, then rerun with EXPECTTEST_ACCEPT=1 to automatically populate the source code with the captured values. It works with both unittest and pytest, and supports multiline strings via triple-quoted literals. The library modifies your Python test files directly when accepting new expectations, rather than storing them in external snapshot files. This keeps test logic and expectations in one place but requires careful version control practices. It's useful when you want to verify complex output (formatted strings, error messages, data structures) without manually writing expected values. Use it for: - Verify formatted output of code generators or transpilers by capturing and versioning the generated code inline. - Test error messages and exception formatting by accepting the actual output as the expected baseline. - Snapshot test complex data structure representations without maintaining separate snapshot files. - Validate multi-line string output in documentation examples or report generation. - Update test expectations in bulk when intentional API changes produce different but correct output. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. expecttest implements inline golden tests where expected outputs are stored directly in Python source code and automatically updated when you run tests with EXPECTTEST_ACCEPT=1. Yes, if you prefer inline snapshots over external snapshot files and your team is comfortable with test files being modified during test runs. The library is stable, permissively licensed, and has no dependencies. The aging maintenance status is not a blocker for a mature, focused tool, but verify it still works smoothly with your pytest or unittest version before adopting it in a new project. ## Install pip install expecttest uv add expecttest poetry add expecttest ## Installing expecttest Before you install: Low friction install with no runtime dependencies. Maintenance is aging—last release was 611 days ago—but the repository is active and not archived, with 88 stars. License in practice: MIT license permits unrestricted use, modification, and distribution with only attribution required. Quickstart: from expecttest import TestCase class MyTest(TestCase): def test_example(self): self.assertExpectedInline(some_func(), """""") # Run: EXPECTTEST_ACCEPT=1 python -m unittest Verify before relying: - Whether the package works with pytest parameterization and fixtures beyond the documented Expect() pattern. - Performance characteristics when updating large numbers of inline expectations in a single test run. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 2.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags golden tests python, inline expect tests, auto-update test assertions, snapshot testing inline, expected output testing, snapshot-testing, test-automation [View on SkillFed](https://skillfed.io/packages/expecttest) · [View on PyPI](https://pypi.org/project/expecttest/)