PIUnit
Добавляет возможность тестировать код с функциями print и input
Установите библиотеку:
pip install piunit
Пример использования:
from main import print_hello_world, log_user_state, get_data
from piunit.test import BasePIUnitTest
class TestOne(BasePIUnitTest):
def test_one(self):
self.assertPrint(print_hello_world, ['Hello, World!'])
self.assertInput(log_user_state, ['Смена пароля', 'Пароль успешно изменён'], True, 'new_pass')
self.assertPrintInput(get_data, [10, 3, 2], ['Результат выполнения кода: 15'])
Описание методов класса BasePIUnitTest:
+ assertPrint(test_func: Callable, prints: SupportsIndex,
all_: bool = False)
Тестирует код с функцией print.
Проверяет, напечаталось ли в print то, что ожидалось.
Args:
test_func: Callable (тестируемый объект)
prints: SupportsIndex (значения для print)
all_: bool (при True - вернёт ошибку если остались неиспользованные
значения)
*args, **kwargs: аргументы для тестируемой функции
+ assertInput(test_func: Callable, inputs: SupportsIndex,
all_: bool = False)
Тестирует код с функцией input.
Возвращает указанные данные при вызове input.
Args:
test_func: Callable (тестируемый объект)
inputs: SupportsIndex (значения для input)
all_: bool (при True, вернёт ошибку если остались неиспользованные
значения)
*args, **kwargs: аргументы для тестируемой функции
+ assertPrintInput(self, test_func: Callable,
inputs: SupportsIndex,
prints: SupportsIndex,
all_: bool = False
):
Тестирует код с функцией print и input.
Подставляет по порядку данные из prints и inputs.
Args:
test_func: Callable (тестируемый объект)
inputs: SupportsIndex (значения для input)
prints: SupportsIndex (значения для print)
all_: bool (при True, вернёт ошибку если остались неиспользованные
значения)
*args, **kwargs: аргументы для тестируемой функции
Metadata
Release files for PIUnit 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| piunit-1.0.5.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PIUnit-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / piunit-1.0.5.tar.gz
| Download URL | piunit-1.0.5.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfe64d8c0340529cfa6b44973787aa157022c96809f04726548e966d93f22765
|
|
BLAKE2b-256 checksum How to use checksums |
42e4654a4ccdcc24605897bfa5cb66940d4d4673861086c68fb634ebced46d50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.0
|
Release files / PIUnit-1.0.5-py3-none-any.whl
| Download URL | PIUnit-1.0.5-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1356a7b1d581db51a3a3df7792c3685b363d6a2ba19582bb4bb052a8a3dd20e6
|
|
BLAKE2b-256 checksum How to use checksums |
a5732d71b8e2144a96fc7d7a0da02c330a4406072390b45b721bf5ce2b0ca0fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.0
|