Repository navigation
veyra-snap: a Python library that writes pytest tests from real runs - #54
Merged
Merged
Conversation
`pip install veyra-snap`, then `veyra-snap run app.py` and `veyra-snap write`: it records what the functions in your project are given and what they return or raise, and writes those real calls as readable pytest tests. - No code changes: sys.monitoring on Python 3.12+ (code outside your project is never watched; a function with 25 cases stops being watched), and sys.settrace on 3.9-3.11. Or `recording()` / `@snap` in code. - Every value is rebuilt from its source and compared, type for type, before it goes in a test; values that can't be (files, connections, NaN, ...) are left out with the reason shown. - Functions that change between calls, or only return None, get no tests. - No dependencies. 71 tests, including an end-to-end run whose generated tests pass and then catch a changed rounding rule. - .github/workflows/veyra-snap.yml: tests on Linux, Windows and macOS with Python 3.9-3.14, and publishing to PyPI with Trusted Publishing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
veyra-snap: run your code, get pytest tests
A new Python library for PyPI, in
python/veyra-snap/.It records what the functions in your project are given and what they return or raise, then writes those real calls as readable, parametrized pytest tests. It's aimed at code without tests, nervous refactors, and locking down a library's behaviour.
How it works
sys.monitoringon Python 3.12+ andsys.settraceon 3.9–3.11. Your libraries, virtual environments and tests are never recorded, and a function stops being watched once it has 25 cases. Measured: library calls ×0.94 (no cost), a hot function of your own ×1.12.Noneget no tests, so the generated tests are never flaky.recording()for a block, or@snapon chosen functions.Tests
twine checkpasses.Publishing (after merge)
veyra-snap, ownerfcopensource, repositoryveyraeditor, workflowveyra-snap.yml, environmentpypi.No tokens or passwords are stored anywhere (Trusted Publishing).
🤖 Generated with Claude Code