Skip to content

Commit

Permalink
Add some extra assertions to make sure the roundtrip produces the sam…
Browse files Browse the repository at this point in the history
…e traceback text.
  • Loading branch information
ionelmc committed Oct 21, 2023
1 parent 8985b95 commit ba23e5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_pickle_exception.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from traceback import format_exception

try:
import copyreg
except ImportError:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ba23e5f

Please sign in to comment.