around

typhoon.test.ranges.around(val, tol=None, tol_p=0.05)

Defines range as a center value with a tolerance around it. This function is used to have more readable code on automated tests.

Parameters:
  • val – Value around which the range will be defined.

  • tol (float) – Absolute tolerance around center value.

  • tol_p (float) – Relative tolerance around center value

Returns:

Range as a tuple (val-tol, val+tol)

Return type:

tuple

Notes

If both tolerances are defined, the absolute tolerance is used.

Examples

Instead of writing ranges manually:

>>> at_val=(5-1,5+1)

or

>>> at_val=(5 - 5*0.01, 5 + 5*0.01)

We can use:

>>> at_val=around(5,tol=1)
>>> at_val=around(5,tol_p=0.01)