From 77fb4ae2e17116ab1b2d33a1d04935c63987feb0 Mon Sep 17 00:00:00 2001 From: Theo Satabin Date: Fri, 17 Mar 2023 11:24:44 +0100 Subject: [PATCH] Comparaison de float dans les tests unitaires via math.isclose --- tests/test_Utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_Utils.py b/tests/test_Utils.py index f5dfe6a..075e7d9 100644 --- a/tests/test_Utils.py +++ b/tests/test_Utils.py @@ -3,6 +3,7 @@ import pytest import os +import math from unittest.mock import * from unittest import mock @@ -52,7 +53,10 @@ def test_reproject_point_ok(): sr_3857 = srs_to_spatialreference("EPSG:3857") sr_ignf = srs_to_spatialreference("IGNF:WGS84G") x,y = reproject_point((43, 3), sr_4326, sr_3857) - assert (x,y) == (333958.4723798207, 5311971.846945471) + + assert math.isclose(x, 333958.4723798207, rel_tol=1e-5) + assert math.isclose(y, 5311971.846945471, rel_tol=1e-5) + x,y = reproject_point((43, 3), sr_4326, sr_ignf) assert (x,y) == (3, 43)