From 5a90ebabf2a446606aea26f9dac3c5ee14c519f5 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Fri, 5 Jun 2026 00:38:53 +0200 Subject: [PATCH] test(review): use pytest.approx for float assertions (SonarQube S1244) SonarQube flagged three float equality checks in the classifier tests (python:S1244, "do not perform equality checks with floating point values"): the _text_quality empty case and the ocr_page_fraction 0.0/1.0 assertions now use pytest.approx. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/unit/test_doc_classifier.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_doc_classifier.py b/tests/unit/test_doc_classifier.py index 57748c47..cc86c80d 100644 --- a/tests/unit/test_doc_classifier.py +++ b/tests/unit/test_doc_classifier.py @@ -57,7 +57,7 @@ def test_text_quality_mashed_tokens_scores_low(): def test_text_quality_empty_is_zero(): - assert clf._text_quality("") == 0.0 + assert clf._text_quality("") == pytest.approx(0.0) # --- routing ----------------------------------------------------------------- @@ -66,7 +66,7 @@ def test_text_quality_empty_is_zero(): def test_digital_pdf_routes_fast(): c = clf.classify_pdf(_digital_pdf()) assert c.recommended_tier == "fast" - assert c.ocr_page_fraction == 0.0 + assert c.ocr_page_fraction == pytest.approx(0.0) assert "image_heavy" not in c.flags assert c.mean_text_quality > 0.8 @@ -74,7 +74,7 @@ def test_digital_pdf_routes_fast(): def test_full_page_image_routes_ocr(): c = clf.classify_pdf(_full_page_image_pdf()) assert c.recommended_tier == "ocr" - assert c.ocr_page_fraction == 1.0 + assert c.ocr_page_fraction == pytest.approx(1.0) assert "image_heavy" in c.flags assert "scanned" in c.flags # no text layer at all