From ba23e5f664adcf8fc7f4fd245263f54ce1d68b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Sat, 21 Oct 2023 17:44:08 +0300 Subject: [PATCH] Add some extra assertions to make sure the roundtrip produces the same traceback text. --- tests/test_pickle_exception.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_pickle_exception.py b/tests/test_pickle_exception.py index d28fb14..f0d8ba6 100644 --- a/tests/test_pickle_exception.py +++ b/tests/test_pickle_exception.py @@ -1,3 +1,5 @@ +from traceback import format_exception + try: import copyreg except ImportError: @@ -52,12 +54,14 @@ def test_install(clear_dispatch_table, how, protocol): if has_python311: new_e.add_note('note 1') new_e.add_note('note 2') - raise new_e + raise new_e from e except Exception as e: exc = e else: raise AssertionError + expected_format_exception = ''.join(format_exception(type(exc), exc, exc.__traceback__)) + print(expected_format_exception) # Populate Exception.__dict__, which is used in some cases exc.x = 1 if has_python3: @@ -88,6 +92,8 @@ def test_install(clear_dispatch_table, how, protocol): if has_python311: assert exc.__notes__ == ['note 1', 'note 2'] + assert expected_format_exception == ''.join(format_exception(type(exc), exc, exc.__traceback__)) + @tblib.pickling_support.install class RegisteredError(Exception):