@@ -198,22 +198,21 @@ def effect(*args, **kwargs):
198
198
199
199
# Check the entire output, end to end
200
200
pyp_error = run_cmd ("pyp 'def f(): 1/0' 'f()'" , check = False )
201
- message = lambda po , pc : ( # noqa
202
- (
203
- "error: Code raised the following exception, "
204
- "consider using --explain to investigate:\n \n "
205
- "Possible reconstructed traceback (most recent call last):\n "
206
- ' File "<pyp>", in <module>\n '
207
- " output = f()\n "
208
- )
209
- + (" ^^^^^^^^^^^\n " if sys .version_info >= (3 , 11 ) else "" )
210
- + (' File "<pyp>", in f\n ' f" { po } 1 / 0{ pc } \n " )
211
- + (" \n " if sys .version_info >= (3 , 11 ) else "" )
212
- + ("ZeroDivisionError: division by zero\n " )
201
+ pyp_error .replace ("(1 / 0)" , "1 / 0" )
202
+ pyp_error = re .sub (r"\n[\s\^]+\n" , "\n " , pyp_error )
203
+ message = (
204
+ "error: Code raised the following exception, "
205
+ "consider using --explain to investigate:\n \n "
206
+ "Possible reconstructed traceback (most recent call last):\n "
207
+ ' File "<pyp>", in <module>\n '
208
+ " output = f()\n "
209
+ ' File "<pyp>", in f\n '
210
+ " 1 / 0\n "
211
+ "ZeroDivisionError: division by zero\n "
213
212
)
214
- print (repr (pyp_error ))
215
- print (repr ( message ( " " , "" ) ))
216
- assert pyp_error == message ( "(" , ")" ) or pyp_error == message ( "" , "" )
213
+ print ("actual" , repr (pyp_error ))
214
+ print ("expected " , repr ( message ))
215
+ assert pyp_error == message
217
216
218
217
# Test tracebacks involving statements with nested child statements
219
218
pyp_error = run_cmd ("""pyp 'if 1 / 0: print("should_not_get_here")'""" , check = False )
0 commit comments