2teez / assertions

simple assertions in python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertions

Description:

A simple assertion using python. It tests and returns either true or false for the condition in consideration.

Functions:

  1. asserts(value: Any) -> bool

Check if the value passed is True. it is diffrent to the core assert. It returns True or False. No exception is returned.

>>> asserts(True)
True

Below test is expected to Fail.

>>> asserts([])
True
  1. assert_eq(value1: Any, value2: Any) -> bool

Gets two positional parameters. Check if the parameters are the same type. Then check if the parameters are the same.

>>> assert_eq("Lagos", "new yoke")
False

>>> assert_eq([0, 1, 2], list(range(3)))
True
  1. asserts_prnt(value: Any) -> None

Prints returned value of the function asserts. Returns None.

  1. assert_eq_prnt(value1: Any, value2: Any, *, show=False) -> None

Prints returned values of the function assert_eq. Returns None

  1. _print_result(status: bool, *, values: list[Any] = [None], show=False) -> None

It prints out either True or False. It can also show the reason, if the result is false. _print_result is a private function in this package. It takes; a bool, a list and a bool variable. It returns None.

  1. printer(show: bool=False)

A decorator to prints assert_eq. This enables assert_eq to prints, without using the print function. It doesn't only prints the result but shows the result expected and what is gotten, if the result is false.

About

simple assertions in python


Languages

Language:Python 100.0%