@@ -29,6 +29,10 @@ class CustomError(Exception):
2929 pass
3030
3131
32+ def strip_locations (tb_text ):
33+ return tb_text .replace (' ~~^~~\n ' , '' ).replace (' ^^^^^^^^^^^^^^^^^\n ' , '' )
34+
35+
3236@pytest .mark .parametrize ('protocol' , [None , * list (range (1 , pickle .HIGHEST_PROTOCOL + 1 ))])
3337@pytest .mark .parametrize ('how' , ['global' , 'instance' , 'class' ])
3438def test_install (clear_dispatch_table , how , protocol ):
@@ -58,12 +62,8 @@ def test_install(clear_dispatch_table, how, protocol):
5862 else :
5963 raise AssertionError
6064
61- expected_format_exception = '' .join (format_exception (type (exc ), exc , exc .__traceback__ )).replace (
62- '~~^~~' ,
63- '^^^^^^^^^^^^^^^^^' ,
64- )
65+ expected_format_exception = strip_locations ('' .join (format_exception (type (exc ), exc , exc .__traceback__ )))
6566
66- print (expected_format_exception )
6767 # Populate Exception.__dict__, which is used in some cases
6868 exc .x = 1
6969 exc .__cause__ .x = 2
@@ -92,7 +92,7 @@ def test_install(clear_dispatch_table, how, protocol):
9292 if has_python311 :
9393 assert exc .__notes__ == ['note 1' , 'note 2' ]
9494
95- assert expected_format_exception == '' .join (format_exception (type (exc ), exc , exc .__traceback__ ))
95+ assert expected_format_exception == strip_locations ( '' .join (format_exception (type (exc ), exc , exc .__traceback__ ) ))
9696
9797
9898@tblib .pickling_support .install
0 commit comments