https://github.com/ianjure/fancytest
A python package that tests function call instances using a simple decorator.
https://github.com/ianjure/fancytest
decorators-python pypi-package python-package
Last synced: 9 months ago
JSON representation
A python package that tests function call instances using a simple decorator.
- Host: GitHub
- URL: https://github.com/ianjure/fancytest
- Owner: ianjure
- Created: 2024-07-25T02:03:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-27T05:19:34.000Z (over 1 year ago)
- Last Synced: 2025-01-26T17:37:20.132Z (11 months ago)
- Topics: decorators-python, pypi-package, python-package
- Language: Python
- Homepage: https://pypi.org/project/fancytest/
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## What is Fancytest?
Fancytest provides a [decorator](https://www.geeksforgeeks.org/decorators-in-python/) to test function call instances in your program. It will provide the simple status of both failed and successful instances.
## How to use Fancytest?
```
pip install fancytest
```
```python
from fancytest import ftest # <-- IMPORT THE PACKAGE
@ftest # <-- ADD THE DECORATOR TO THE FUNCTION YOU WANT TO TEST (@ftest)
def add(a, b):
return a + b
@ftest # <-- ADD THE DECORATOR TO THE FUNCTION YOU WANT TO TEST (@ftest)
def squared(a):
return a * a
# FAIL
f = add(2, "b")
squared(f)
# SUCCESS
s = add(1,2)
squared(s)
```
#### Fancytest will output all instances with their parameters and status.
```
INSTANCE: add(2, 'b') : FAILED
ERROR: unsupported operand type(s) for +: 'int' and 'str'
INSTANCE: squared(None) : FAILED
ERROR: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
INSTANCE: add(1, 2) : SUCCESS
TIME: 0.000ms
INSTANCE: squared(3) : SUCCESS
TIME: 0.000ms
```