99import location
1010import paths
1111import utils
12+ import i18n
1213
1314_DEBUG = False
1415def _debug (s ):
@@ -147,23 +148,21 @@ def printTestResults(prefix='', loadingFailed=False):
147148 failing = _testCount ['failing' ]
148149 bad = '🙁'
149150 good = '😀'
150- tests = f'{ prefix } { total } Tests'
151- if total == 1 :
152- tests = f'{ prefix } { total } Test'
151+ tests = f'{ prefix } ' + i18n .numTests (total )
153152 if total == 0 :
154153 pass
155154 elif failing == 0 :
156155 if loadingFailed :
157- print (f'{ tests } , Abbruch der Ausführung { bad } ' )
156+ print (f'{ tests } , { i18n . tr ( "Stop of execution" ) } { bad } ' )
158157 elif total == 1 :
159- print (f'1 erfolgreicher Test { good } ' )
158+ print (f'{ i18n . tr ( "1 successful test" ) } { good } ' )
160159 else :
161- print (f'{ tests } , alle erfolgreich { good } ' )
160+ print (f'{ tests } , { i18n . tr ( "all successful" ) } { good } ' )
162161 else :
163162 if loadingFailed :
164- print (f'{ tests } , { failing } Fehler und Abbruch der Ausführung { bad } ' )
163+ print (f'{ tests } , { i18n . numFailing ( failing ) } and stop of execution { bad } ' )
165164 else :
166- print (f'{ tests } , { failing } Fehler { bad } ' )
165+ print (f'{ tests } , { i18n . numFailing ( failing ) } { bad } ' )
167166 return {'total' : total , 'failing' : failing }
168167
169168def checkEq (actual , expected ):
@@ -197,20 +196,20 @@ def checkGeneric(actual, expected, *, structuralObjEq=True, floatEqWithDelta=Tru
197196 frame = stack [2 ] if len (stack ) > 2 else None
198197 if frame :
199198 filename = paths .canonicalizePath (frame .filename )
200- caller = f"Datei { filename } , Zeile { frame .lineno } : "
199+ caller = i18n .tr ('File {filename}, line {lineno}: ' ,
200+ filename = filename , lineno = frame .lineno )
201201 else :
202202 caller = ""
203203 def fmt (x ):
204204 if type (x ) == str :
205205 return repr (x )
206206 else :
207207 return str (x )
208- msg = f"{ caller } Erwartet wird { fmt (expected )} , aber das " \
209- f"Ergebnis ist { fmt (actual )} "
208+ msg = caller + i18n .checkExpected (fmt (expected ), fmt (actual ))
210209 if _dieOnCheckFailures ():
211210 raise Exception (msg )
212211 else :
213- print ("FEHLER in " + msg )
212+ print (i18n . tr ( 'ERROR in ' ) + msg )
214213
215214def checkFail (msg : str ):
216215 if not _checksEnabled :
@@ -220,15 +219,17 @@ def checkFail(msg: str):
220219 if _dieOnCheckFailures ():
221220 raise Exception (msg )
222221 else :
223- print ("FEHLER: " + msg )
222+ print (i18n . tr ( 'ERROR: ' ) + msg )
224223
225224def uncoveredCase ():
226225 stack = inspect .stack ()
227226 if len (stack ) > 1 :
228227 caller = stack [1 ]
229- raise Exception (f"{ caller .filename } , Zeile { caller .lineno } : ein Fall ist nicht abgedeckt" )
228+ callerStr = i18n .tr ('File {filename}, line {lineno}: ' ,
229+ filename = caller .filename , lineno = caller .lineno )
230+ raise Exception (callerStr + i18n .tr ('uncovered case' ))
230231 else :
231- raise Exception (f"Ein Fall ist nicht abgedeckt" )
232+ raise Exception (i18n . tr ( 'Uncovered case' ) )
232233
233234#
234235# Deep equality
@@ -328,7 +329,8 @@ def todo(msg=None):
328329
329330def impossible (msg = None ):
330331 if msg is None :
331- msg = 'Das Unmögliche ist passiert!'
332+ msg = i18n .tr ('The impossible happened!' )
333+ 'Das Unmögliche ist passiert!'
332334 raise errors .ImpossibleError (msg )
333335
334336# Additional functions and aliases
0 commit comments