Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Sometimes there is a situation when we want to check if the tested result is within the specified range.  

Firstly let's write a function like in the snipped below:

Code Block
languagepy
import math


def get_pi():
    return math.pi


To test get_pi function correctness we will just check if the result is in the range of 3.1415 to 3.1416. 

Code Block
languagepy
from sources.operations import get_pi


def test_get_pi():
    assert 3.1415 <= get_pi() <= 3.1416