45 lines
1.8 KiB
Diff
45 lines
1.8 KiB
Diff
|
From 66e14cdd101e4214cca6acca8f48b9abe4f75729 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= <contact@ionelmc.ro>
|
||
|
Date: Fri, 15 Dec 2023 16:52:07 +0200
|
||
|
Subject: [PATCH] More aggressive location stripping. Ref #74.
|
||
|
|
||
|
---
|
||
|
tests/test_pickle_exception.py | 12 ++++++------
|
||
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
||
|
|
||
|
Index: tblib-3.0.0/tests/test_pickle_exception.py
|
||
|
===================================================================
|
||
|
--- tblib-3.0.0.orig/tests/test_pickle_exception.py
|
||
|
+++ tblib-3.0.0/tests/test_pickle_exception.py
|
||
|
@@ -29,6 +29,10 @@ class CustomError(Exception):
|
||
|
pass
|
||
|
|
||
|
|
||
|
+def strip_locations(tb_text):
|
||
|
+ return tb_text.replace(' ~~^~~\n', '').replace(' ^^^^^^^^^^^^^^^^^\n', '')
|
||
|
+
|
||
|
+
|
||
|
@pytest.mark.parametrize('protocol', [None, *list(range(1, pickle.HIGHEST_PROTOCOL + 1))])
|
||
|
@pytest.mark.parametrize('how', ['global', 'instance', 'class'])
|
||
|
def test_install(clear_dispatch_table, how, protocol):
|
||
|
@@ -58,8 +62,8 @@ def test_install(clear_dispatch_table, h
|
||
|
else:
|
||
|
raise AssertionError
|
||
|
|
||
|
- expected_format_exception = ''.join(format_exception(type(exc), exc, exc.__traceback__))
|
||
|
- print(expected_format_exception)
|
||
|
+ expected_format_exception = strip_locations(''.join(format_exception(type(exc), exc, exc.__traceback__)))
|
||
|
+
|
||
|
# Populate Exception.__dict__, which is used in some cases
|
||
|
exc.x = 1
|
||
|
exc.__cause__.x = 2
|
||
|
@@ -88,7 +92,7 @@ def test_install(clear_dispatch_table, h
|
||
|
if has_python311:
|
||
|
assert exc.__notes__ == ['note 1', 'note 2']
|
||
|
|
||
|
- assert expected_format_exception == ''.join(format_exception(type(exc), exc, exc.__traceback__))
|
||
|
+ assert expected_format_exception == strip_locations(''.join(format_exception(type(exc), exc, exc.__traceback__)))
|
||
|
|
||
|
|
||
|
@tblib.pickling_support.install
|