@@ -29,6 +29,10 @@ class CustomError(Exception):
29
29
pass
30
30
31
31
32
+ def strip_locations (tb_text ):
33
+ return tb_text .replace (' ~~^~~\n ' , '' ).replace (' ^^^^^^^^^^^^^^^^^\n ' , '' )
34
+
35
+
32
36
@pytest .mark .parametrize ('protocol' , [None , * list (range (1 , pickle .HIGHEST_PROTOCOL + 1 ))])
33
37
@pytest .mark .parametrize ('how' , ['global' , 'instance' , 'class' ])
34
38
def test_install (clear_dispatch_table , how , protocol ):
@@ -58,12 +62,8 @@ def test_install(clear_dispatch_table, how, protocol):
58
62
else :
59
63
raise AssertionError
60
64
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__ )))
65
66
66
- print (expected_format_exception )
67
67
# Populate Exception.__dict__, which is used in some cases
68
68
exc .x = 1
69
69
exc .__cause__ .x = 2
@@ -92,7 +92,7 @@ def test_install(clear_dispatch_table, how, protocol):
92
92
if has_python311 :
93
93
assert exc .__notes__ == ['note 1' , 'note 2' ]
94
94
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__ ) ))
96
96
97
97
98
98
@tblib .pickling_support .install
0 commit comments