1from datetime import timedelta
2from pytest import approx
3
4# 10.0 ± 2.0e+00
5approx_expected_time = approx(
6 timedelta(seconds=10).total_seconds(),
7 abs=timedelta(seconds=2).total_seconds()
8)
9
10assert timedelta(seconds=13).total_seconds() == approx_expected_time # false
11assert timedelta(seconds=12).total_seconds() == approx_expected_time # true
12assert timedelta(seconds= 8).total_seconds() == approx_expected_time # true
13assert timedelta(seconds= 7).total_seconds() == approx_expected_time # false
14