Tests for lazy (smart) devs
Project description
What is this?
This is a package that makes squashing bugs easy, SO easy that even lazy people like me can do it.
How do I use this?
pip install grug_test
from grug_test import GrugTest
# 1. say where the tests will be saved
grug_test = GrugTest(
project_folder=".",
test_folder="./tests/grug_tests",
fully_disable=os.environ.get("PROD")!=None,
replay_inputs=os.environ.get("RUN_TEST_CASES")!=None,
record_io=True, # set to false when want a faster runtime while debugging
# NOTE: fully_disable does override this setting
)
# 2. slap @grug_test on any of your pure-functions
@grug_test
def repeat(a,times):
for _ in range(times):
a += f"{a}"
return a
- That's all the setup!
- The "test cases" are generated when you set
GrugTest(record_io=True)
and run your normal workflow - Commit your generated "test cases" (input/output files) to git
- Brea--I mean ""optimize"" your code real good
- Now test your totally-not-broken code by again, running your normal workflow BUT with
GrugTest(replay_inputs=True)
- Once that's finished, the git-diff will show you all your failing test cases
- If you like/want the new output; well you just generated your new test cases; commit the files and you're done
Q&A
Does this work with ANY pure function?
- Almost, the arguments need to be hashable and seralizable. For example, if you pass a function as an argument then grug_test can't really save/load that function when
replay_inputs=True
. However, you can make almost any class seralizable, just checkout how to make a class work with python-pickle, or (even better) dofrom grug_test import yaml
and make your class be yaml-seralizable (tutorial/example here)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
grug_test-0.0.1.tar.gz
(6.5 MB
view hashes)
Built Distribution
grug_test-0.0.1-py3-none-any.whl
(697.8 kB
view hashes)
Close
Hashes for grug_test-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc184a9e151c55f94286c16e7e7a7a26ab27ff100ee79954fbcba953c5f12509 |
|
MD5 | 68020e7b4a2c6ae7bbc722bf86510242 |
|
BLAKE2b-256 | 71d7b6a1980c5d87d37de5a9d4f36f2282061a9c07e178b1a20261cf85e4ad85 |