Skip to content

Commit f68abc9

Browse files
committed
Use pytest.approx for float comparisons in config-schema test (Sonar S1244)
1 parent f4387aa commit f68abc9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

test/unit_test/headless/test_config_schema_batch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Headless tests for typed config schema validation. Pure stdlib, no Qt."""
22
import json
33

4+
import pytest
5+
46
import je_auto_control as ac
57
from je_auto_control.utils.config_schema import (
68
ConfigField, ConfigSchema, coerce, validate_config,
@@ -9,7 +11,7 @@
911

1012
def test_coerce_types():
1113
assert coerce("8080", "int") == 8080
12-
assert coerce("1.5", "float") == 1.5
14+
assert coerce("1.5", "float") == pytest.approx(1.5)
1315
assert coerce("yes", "bool") is True
1416
assert coerce("off", "bool") is False
1517
assert coerce(5, "str") == "5"
@@ -48,7 +50,7 @@ def test_choices_constraint():
4850
def test_from_dict_and_defaults():
4951
report = validate_config(
5052
{"timeout": {"type": "float", "default": 1.0}}, {})
51-
assert report["config"] == {"timeout": 1.0}
53+
assert report["config"]["timeout"] == pytest.approx(1.0)
5254

5355

5456
# --- wiring ---------------------------------------------------------------

0 commit comments

Comments
 (0)