Skip to main content

Automatically test your functions to see if you have changed their behavior by mistake!

Project description

Contributors Stargazers Issues PyPi version Python 3


Logo

AutoTest!Reg

Automatically test your functions to see if you have changed their behavior by mistake!


View Demo · Report Bug

About The Project

Have you ever spent hours reworking someone else's code, trying not to break anything, only to realize at the last moment that something doesn't work anymore, but not knowing at which step you introduced the bug? So frustrating!

AutoTest!Reg allows you to automatically track the code you are working on and not introduce any regression, without writing a single test!

Getting Started

Using AutoTest!Reg requires no effort at all!

Install AutoTest!Reg with pip :

pip install autotestreg

Import AutoTest!Reg into your tests, adding this line:

import autotestreg

To follow a function my_func, this code is all you need:

from autotestreg import autotest_func

@autotest_func
def my_func():
    ...

To track an entire module mypackage, with all the functions and methods it contains:

from autotestreg import autotest_module
import mypackage

autotest_module(mypackage)

In your tests, juste use your functions to trigger Autotest!Reg smart regresion testing.

Results

If no regression was introduced when you modified the code, your tests will pass.
Otherwise, AutoTest!Reg will give you the function whose behavior was changed.

AutotestError: Output changed in mypackage.file1/function1, for input x=1
@@ -3 +3 @@
-old+new

The true power of Autotest!

The real power of Autotest! lies here: you are not forced to write tons of code to explicitly call all of your functions. If you have a main function that recursively calls all sub-functions in the module, Autotest!reg will still track and check all sub-functions for regressions!

# before, you needed to explicitely call all functions that neeeded tests and assert their results
assert fonc1(...) == { ... }
obj = Object2(...)
assert obj2.method1(...) == ...

# now, just call your main function, after registering your module
from autotestreg import autotest_module
import mypackage

autotest_module(mypackage)
mypackage.main()

Use in python notebooks

You can use AutoTest!Reg for functions defined in a python notebooks. Just add the import and the autotest_func decorators in your notebook cells.

Advanced usage

You can use AutoTest!Reg as a pre-commit hook:

  1. Create some test files using autotestreg (e.g. some_tests.py)
  • This file must contain at the top from autotestreg import set_interactive and set_interactive(False)
  1. Modify the pre-commit hook script: touch .git/hooks/pre-commit
  2. Add this inside:
#!/bin/sh
# Dont forget to activate your env if needed.
python some_tests.py
  1. Make the pre-commit file executable: chmod +x .git/hooks/pre-commit

(back to top)

Contributing

(Section in english)
I want to add a lot of functionnalities to this project, but I don't have much time to work on it. Contributions are welcome!

To install in dev mode, use pip install -e .

(back to top)

How to contribute

Contributing is an awesome way to learn, inspire, and help others. Any contributions you make are greatly appreciated, even if it's just about styling and best practices.

If you have a suggestion that would make this project better, please fork the repo and create a pull request.
Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/YourAmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Authors

This library was created by Nicolas MICAUX.
You might also be interested by foolproof

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autotestreg-0.3.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autotestreg-0.3.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file autotestreg-0.3.0.tar.gz.

File metadata

  • Download URL: autotestreg-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for autotestreg-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6737dd31711edc42523f4b3216cc3bcb65c65d8b4fd2720ed3e2840be72bbb6d
MD5 cb12085c67e2bdf38052d87c1338115f
BLAKE2b-256 a1c08f1d4014b00e932da236ac2f66d82212593ab123d82a2e6bc12495604359

See more details on using hashes here.

File details

Details for the file autotestreg-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: autotestreg-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for autotestreg-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 903088ab5bf7e8e1fb5b0920e12851fcb0d16594abcdf4ab0c43cc1e2783ff87
MD5 0b469d90b9ead8566dc7a86d195c285d
BLAKE2b-256 db8097557b374c8fc84236ae2f720430d2d6a8c2eb77ffa42939837c6a1c4441

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page