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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
23cc6cca43
commit
5a90ebabf2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user