@@ -155,6 +155,42 @@ def test_checks_fuzzy() -> None:
155155 assert len (result [0 ]) == 10
156156
157157
158+ def test_error_on_fuzzy () -> None :
159+ """Test error_on_fuzzy option that raises an error when fuzzy strings are found."""
160+ po_check = PoCheck ()
161+ po_check .set_check ("error_on_fuzzy" )
162+ result = po_check .check_files ([local_path ("fr_errors.po" )])
163+
164+ # be sure we have one file in result
165+ assert len (result ) == 1
166+
167+ # the file should have an error for the fuzzy string
168+ assert len (result [0 ]) == 1
169+
170+ # check the error report
171+ report = result [0 ][0 ]
172+ assert report .idmsg == "fuzzy"
173+ assert report .message == "fuzzy string found"
174+ assert report .fuzzy is True
175+ assert "fr_errors.po" in report .filename
176+ assert report .line == 58 # Line where the fuzzy string starts
177+ assert report .mid == "Tested 3"
178+ assert report .mstr == "Testé 3."
179+
180+
181+ def test_error_on_fuzzy_no_fuzzy_strings () -> None :
182+ """Test error_on_fuzzy option when there are no fuzzy strings."""
183+ po_check = PoCheck ()
184+ po_check .set_check ("error_on_fuzzy" )
185+ result = po_check .check_files ([local_path ("fr.po" )])
186+
187+ # be sure we have one file in result
188+ assert len (result ) == 1
189+
190+ # the file should have no errors
191+ assert len (result [0 ]) == 0
192+
193+
158194def test_checks_noqa () -> None :
159195 """Test checks on a gettext file including `noqa`-commented lines."""
160196 po_check = PoCheck ()
0 commit comments