didatictests-0.0.9
توضیحات
Build simple tests to validate functions prints and outputs with configurable args, kwargs and simulated user inputs
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | didatictests-0.0.9 |
| نام | didatictests |
| نسخه کتابخانه | 0.0.9 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Lincoln Makoto Kawakami |
| ایمیل نویسنده | lmkawakami@hotmail.com |
| آدرس صفحه اصلی | https://github.com/lmkawakami/didatictests |
| آدرس اینترنتی | https://pypi.org/project/didatictests/ |
| مجوز | MIT license |
# didatictests
[](https://pypi.org/project/didatictests/)
[](https://pypi.org/project/didatictests/)
[](https://pypi.org/project/didatictests/)
[](https://github.com/lmkawakami/didatictests/commits/main)
[](https://github.com/lmkawakami/didatictests/commits/main)
[](https://github.com/lmkawakami/didatictests/blob/main/LICENSE)
[](https://github.com/lmkawakami/didatictests/actions)
[](https://lmkawakami.github.io/didatictests/)
[](https://codecov.io/gh/lmkawakami/didatictests)
---
## Features
- Run functions with preconfigured simulated keyboard inputs
- Build simple tests to validate functions prints and outputs with configurable args, kwargs and simulated user inputs
## Installation
**Stable Release:** `pip install didatictests`<br>
**Development Head:** `pip install git+https://github.com/lmkawakami/didatictests.git`
## Documentation
[Notebook showcase em português](notebooks/exemplos.ipynb)
[Notebook de funcionalidades extras em português](notebooks/brindes.ipynb)
For full package documentation please visit [lmkawakami.github.io/didatictests](https://lmkawakami.github.io/didatictests).
## Quick Start
```python
from didatictests import Didatic_test
```
Demo function: `the_function(arg)`:
- receives 1 argument `arg`
- receives 1 user input `inp`
- calculates `total = arg + int(inp)`
- prints `total`
- return `total`
```python
def the_function(arg):
inp = input("One number, please: ")
total = arg + int(inp)
print(total)
return total
```
Create and run some tests:
---
### Test-1
```python
test1 = Didatic_test(
fn = the_function,
args = Dt.parse_args(40),
keyboard_inputs = ('2'),
test_name = 'This one shall pass!',
expected_output = 42,
expected_prints = '42\n',
run_prints_test = True,
run_output_test = True,
verbose=True
)
test1.run()
```
- print:
```
Case: This one shall pass!
[I]: One number, please: 2
[P]: 42
outputs: ✔️ prints: ✔️
---------------------------------------------------
```
- return:
```python
{'output_is_correct': True, 'print_is_correct': True, 'test_failed': False, 'test_done': True}
```
---
### Test-2
```python
test2 = Didatic_test(
fn = the_function,
args = Dt.parse_args(40),
keyboard_inputs = ('2'),
test_name = 'You Shall Not Pass!!!',
expected_output = 42,
expected_prints = '13\n',
run_prints_test = True,
run_output_test = True,
verbose=True
)
test2.run()
```
- print:
```
Case: You Shall Not Pass!!!
[I]: One number, please: 2
[P]: 42
outputs: ✔️ prints: ❌
➖ Function args: (40,) {}
➖ Keyboard inputs: ('2',)
✔️ Function outputs: 42
➖ Expected output: 42
❌ fn internal prints: 42
➖ Expected prints: 13
---------------------------------------------------
```
- return:
```python
{'output_is_correct': True, 'print_is_correct': False, 'test_failed': False, 'test_done': True}
```
---
### Test-3
```python
test3 = Didatic_test(
fn = the_function,
args = Dt.parse_args('forty'),
keyboard_inputs = ('two'),
test_name = 'Error demo',
expected_output = 42,
expected_prints = '42\n',
run_prints_test = True,
run_output_test = True,
verbose=True
)
test3.run()
```
- print:
```
Case: Error demo
🚨⚠️🚨⚠️🚨 Error! 💀💀💀
<class 'ValueError'>
("invalid literal for int() with base 10: 'two'",)
invalid literal for int() with base 10: 'two'
[I]: One number, please: two
---------------------------------------------------
```
- return:
```python
{'output_is_correct': False, 'print_is_correct': False, 'test_failed': True, 'test_done': False}
```
## Development
See [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.
[**MIT license**](LICENSE)
نیازمندی
| مقدار | نام |
|---|---|
| >=5.2 | pytest-runner |
| >=19.10b0 | black |
| >=2.1.4 | codecov |
| >=3.8.3 | flake8 |
| >=3.2.1 | flake8-debugger |
| >=5.4.3 | pytest |
| >=2.9.0 | pytest-cov |
| >=0.11 | pytest-raises |
| >=1.0.1 | bump2version |
| >=5.1 | coverage |
| >=7.15.0 | ipython |
| >=0.2.7 | m2r2 |
| >=3.4.3 | Sphinx |
| >=0.5.1 | sphinx-rtd-theme |
| >=3.15.2 | tox |
| >=3.1.1 | twine |
| >=0.34.2 | wheel |
| >=5.2 | pytest-runner |
| >=19.10b0 | black |
| >=2.1.4 | codecov |
| >=3.8.3 | flake8 |
| >=3.2.1 | flake8-debugger |
| >=5.4.3 | pytest |
| >=2.9.0 | pytest-cov |
| >=0.11 | pytest-raises |
| >=1.0.1 | bump2version |
| >=5.1 | coverage |
| >=7.15.0 | ipython |
| >=0.2.7 | m2r2 |
| >=3.4.3 | Sphinx |
| >=0.5.1 | sphinx-rtd-theme |
| >=3.15.2 | tox |
| >=3.1.1 | twine |
| >=0.34.2 | wheel |
| >=5.2 | pytest-runner |
| >=19.10b0 | black |
| >=2.1.4 | codecov |
| >=3.8.3 | flake8 |
| >=3.2.1 | flake8-debugger |
| >=5.4.3 | pytest |
| >=2.9.0 | pytest-cov |
| >=0.11 | pytest-raises |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl didatictests-0.0.9:
pip install didatictests-0.0.9.whl
نصب پکیج tar.gz didatictests-0.0.9:
pip install didatictests-0.0.9.tar.gz