@@ -160,7 +160,33 @@ def test_replace_formatters_python(self):
160160 def test_spelling_id (self ):
161161 """Test spelling on source messages (English) of gettext files."""
162162 po_check = PoCheck ()
163- po_check .set_spelling_options ('id' , None , local_path ('pwl.txt' ))
163+ pwl_files = [local_path ('pwl1.txt' )]
164+ po_check .set_spelling_options ('id' , None , pwl_files )
165+ result = po_check .check_files ([local_path ('fr_spelling_id.po' )])
166+
167+ # be sure we have 1 file in result
168+ self .assertEqual (len (result ), 1 )
169+
170+ # the file has 2 spelling errors: "Thsi" and "errro"
171+ errors = result [0 ][1 ]
172+ self .assertEqual (len (errors ), 3 )
173+ for i , word in enumerate (('Thsi' , 'testtwo' , 'errro' )):
174+ self .assertEqual (errors [i ].idmsg , 'spelling-id' )
175+ self .assertTrue (isinstance (errors [i ].message , list ))
176+ self .assertEqual (len (errors [i ].message ), 1 )
177+ self .assertEqual (errors [i ].message [0 ], word )
178+
179+ def test_spelling_id_multilpe_pwl (self ):
180+ """
181+ Test spelling on source messages (English) of gettext files
182+ using multiple personal word lists.
183+ """
184+ po_check = PoCheck ()
185+ pwl_files = [
186+ local_path ('pwl1.txt' ),
187+ local_path ('pwl2.txt' ),
188+ ]
189+ po_check .set_spelling_options ('id' , None , pwl_files )
164190 result = po_check .check_files ([local_path ('fr_spelling_id.po' )])
165191
166192 # be sure we have 1 file in result
@@ -178,7 +204,39 @@ def test_spelling_id(self):
178204 def test_spelling_str (self ):
179205 """Test spelling on translated messages of gettext files."""
180206 po_check = PoCheck ()
181- po_check .set_spelling_options ('str' , None , local_path ('pwl.txt' ))
207+ pwl_files = [local_path ('pwl1.txt' )]
208+ po_check .set_spelling_options ('str' , None , pwl_files )
209+ result = po_check .check_files ([local_path ('fr_spelling_str.po' ),
210+ local_path ('fr_language.po' )])
211+
212+ # be sure we have 2 files in result
213+ self .assertEqual (len (result ), 2 )
214+
215+ # first file has 3 spelling errors: "CecX", "aabbcc" and "xxyyzz"
216+ errors = result [0 ][1 ]
217+ self .assertEqual (len (errors ), 4 )
218+ for i , word in enumerate (('testtwo' , 'CecX' , 'aabbcc' , 'xxyyzz' )):
219+ self .assertEqual (errors [i ].idmsg , 'spelling-str' )
220+ self .assertTrue (isinstance (errors [i ].message , list ))
221+ self .assertEqual (len (errors [i ].message ), 1 )
222+ self .assertEqual (errors [i ].message [0 ], word )
223+
224+ # second file has 1 error: dict/language "xyz" not found
225+ errors = result [1 ][1 ]
226+ self .assertEqual (len (errors ), 1 )
227+ self .assertEqual (errors [0 ].idmsg , 'dict' )
228+
229+ def test_spelling_str_multiple_pwl (self ):
230+ """
231+ Test spelling on translated messages of gettext files
232+ using multiple personal word lists.
233+ """
234+ po_check = PoCheck ()
235+ pwl_files = [
236+ local_path ('pwl1.txt' ),
237+ local_path ('pwl2.txt' ),
238+ ]
239+ po_check .set_spelling_options ('str' , None , pwl_files )
182240 result = po_check .check_files ([local_path ('fr_spelling_str.po' ),
183241 local_path ('fr_language.po' )])
184242
@@ -209,8 +267,8 @@ def test_spelling_bad_pwl(self):
209267 """Test spelling with a bad pwl option."""
210268 po_check = PoCheck ()
211269 try :
212- po_check . set_spelling_options ( 'str' , None ,
213- local_path ( 'pwl_does_not_exist.txt' ) )
270+ pwl_files = [ local_path ( 'pwl_does_not_exist.txt' )]
271+ po_check . set_spelling_options ( 'str' , None , pwl_files )
214272 except IOError :
215273 pass # this exception is expected
216274 else :
0 commit comments