1
+ import math
2
+
1
3
from _helper .time_fractions import (random_microseconds_as_ns ,
2
4
random_milliseconds_as_ns ,
3
5
random_seconds_as_ns )
@@ -12,7 +14,7 @@ def test_count_microseconds_to_float() -> None:
12
14
rounded_microseconds_to_float = round (TimeFractions (
13
15
mock_elapsed_time_ns ).count_microseconds_to_float (), float_precision )
14
16
rounded_mock_microseconds_to_float = round (mock_elapsed_time_ns / 1000 , float_precision )
15
- assert rounded_microseconds_to_float == rounded_mock_microseconds_to_float
17
+ assert math . isclose ( rounded_microseconds_to_float , rounded_mock_microseconds_to_float , rel_tol = 1e-6 )
16
18
17
19
18
20
def test_count_milliseconds_to_float () -> None :
@@ -22,7 +24,7 @@ def test_count_milliseconds_to_float() -> None:
22
24
rounded_milliseconds_to_float = round (TimeFractions (
23
25
mock_elapsed_time_ns ).count_milliseconds_to_float (), float_precision )
24
26
rounded_mock_milliseconds_to_float = round (mock_elapsed_time_ns / 1000 / 1000 , float_precision )
25
- assert rounded_milliseconds_to_float == rounded_mock_milliseconds_to_float
27
+ assert math . isclose ( rounded_milliseconds_to_float , rounded_mock_milliseconds_to_float , rel_tol = 1e-9 )
26
28
27
29
28
30
def test_count_seconds_to_float () -> None :
@@ -31,4 +33,4 @@ def test_count_seconds_to_float() -> None:
31
33
mock_elapsed_time_ns = random_seconds_as_ns ()
32
34
rounded_seconds_to_float = round (TimeFractions (mock_elapsed_time_ns ).count_seconds_to_float (), float_precision )
33
35
rounded_mock_seconds_to_float = round (mock_elapsed_time_ns / 1000 / 1000 / 1000 , float_precision )
34
- assert rounded_seconds_to_float == rounded_mock_seconds_to_float
36
+ assert math . isclose ( rounded_seconds_to_float , rounded_mock_seconds_to_float , rel_tol = 1e-12 )
0 commit comments