Tests for lazy (smart) devs
Project description
What is this?
Simple automated tests; for grug devs like me who don't have time to test.
How do I use this?
pip install grug_test
In your main.py equivlent:
from grug_test import GrugTest
import os
# 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=os.environ.get("RECORD")!=None,
)
# 2. slap @grug_test on any of your pure-functions
@grug_test(max_io=100)
def repeat(a,times):
for _ in range(times):
a += f"{a}"
return a
- That's all the setup!
RECORD=True python ./main.pywill record tests for youRUN_TEST_CASES=True python ./main.pywill check your functionsPROD=True python ./main.pywill run with grug totally disabled- Make sure to commit the generated tests to git
- When you do
RUN_TEST_CASES=True, the git-diff will show you any problems - If you like the changes, well ✨volia✨ the git changes are your freshly-written test cases
- If you don't like the changes, well then it looks like you've got some dev work to do
- thats it
- When you do
Q&A
Does this work with @staticmethod?
- Yes but you have to put the decorator it on the line BELOW the
@staticmethod
Does this work with ANY pure function?
- Almost, the arguments need to be seralizable. For example, if you pass a lambda function as an argument then grug_test can't really save/load that lambda function when
replay_inputs=True. However, you can make almost any normal class seralizable, just checkout a tutorial on making a class work with python-pickle, or (even better) dofrom grug_test import yamland 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.2.0.tar.gz
(6.6 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
grug_test-0.2.0-py3-none-any.whl
(647.4 kB
view details)
File details
Details for the file grug_test-0.2.0.tar.gz.
File metadata
- Download URL: grug_test-0.2.0.tar.gz
- Upload date:
- Size: 6.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/6.6.0 pkginfo/1.9.6 requests/2.30.0 requests-toolbelt/1.0.0 tqdm/4.65.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57fa1620799773b9c774fd870a8fd2c79f4a3091ffc0b7b274e728364b69a9e5
|
|
| MD5 |
068360e7b59285142ba5a27a148d7d2c
|
|
| BLAKE2b-256 |
5a92e1f035fbc2041509c4aca0b6d308eb9d06213efcdac715362db67cec69b7
|
File details
Details for the file grug_test-0.2.0-py3-none-any.whl.
File metadata
- Download URL: grug_test-0.2.0-py3-none-any.whl
- Upload date:
- Size: 647.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/6.6.0 pkginfo/1.9.6 requests/2.30.0 requests-toolbelt/1.0.0 tqdm/4.65.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdca7862bb9f3b0ed42c01d66fb8811afe032468798fc9a9c7b9cdaf3c7c191d
|
|
| MD5 |
3e1f498029a6c1e08419e634a7da8f20
|
|
| BLAKE2b-256 |
6698a36a0dacc869ff7931b3a9f3371864f4e795dd1405742e1edab144169a37
|