Skip to main content

Library for convenient code testing with print and input functions

Project description

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: аргументы для тестируемой функции

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

piunit-1.0.5.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

PIUnit-1.0.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file piunit-1.0.5.tar.gz.

File metadata

  • Download URL: piunit-1.0.5.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for piunit-1.0.5.tar.gz
Algorithm Hash digest
SHA256 dfe64d8c0340529cfa6b44973787aa157022c96809f04726548e966d93f22765
MD5 e89e584e8899fbd023aea56ea9f44c8e
BLAKE2b-256 42e4654a4ccdcc24605897bfa5cb66940d4d4673861086c68fb634ebced46d50

See more details on using hashes here.

File details

Details for the file PIUnit-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: PIUnit-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for PIUnit-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1356a7b1d581db51a3a3df7792c3685b363d6a2ba19582bb4bb052a8a3dd20e6
MD5 530d1db08b7247b0cdc9b7c577f68df8
BLAKE2b-256 a5732d71b8e2144a96fc7d7a0da02c330a4406072390b45b721bf5ce2b0ca0fa

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