This repository was archived by the owner on Nov 2, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ def __copy__(self):
5050 new_group .__traceback__ = self .__traceback__
5151 new_group .__context__ = self .__context__
5252 new_group .__cause__ = self .__cause__
53+ new_group .__suppress_context__ = self .__suppress_context__
5354 return new_group
5455
5556 def __str__ (self ):
Original file line number Diff line number Diff line change 1+ import copy
12import pytest
23
34from exceptiongroup import ExceptionGroup
45
56
7+ def raise_group ():
8+ try :
9+ 1 / 0
10+ except Exception as e :
11+ raise ExceptionGroup ("ManyError" , [e ], [str (e )]) from e
12+
13+
614def test_exception_group_init ():
715 memberA = ValueError ("A" )
816 memberB = RuntimeError ("B" )
@@ -47,3 +55,19 @@ def test_exception_group_str():
4755 assert "ExceptionGroup: " in repr (group )
4856 assert "memberA" in repr (group )
4957 assert "memberB" in repr (group )
58+
59+
60+ def test_exception_group_copy ():
61+ try :
62+ raise_group ()
63+ except BaseException as e :
64+ group = e
65+ group .__suppress_context__ = False
66+ another_group = copy .copy (group )
67+ assert group .message == another_group .message
68+ assert group .exceptions == another_group .exceptions
69+ assert group .sources == another_group .sources
70+ assert group .__traceback__ is another_group .__traceback__
71+ assert group .__context__ is another_group .__context__
72+ assert group .__cause__ is another_group .__cause__
73+ assert group .__suppress_context__ == another_group .__suppress_context__
You can’t perform that action at this time.
0 commit comments