@@ -59,15 +59,26 @@ def test_exception_group_str():
59
59
60
60
def test_exception_group_copy ():
61
61
try :
62
- raise_group ()
63
- except BaseException as e :
62
+ raise_group () # the exception is raise by `raise...from..`
63
+ except ExceptionGroup as e :
64
64
group = e
65
+
66
+ another_group = copy .copy (group )
67
+ assert another_group .message == group .message
68
+ assert another_group .exceptions == group .exceptions
69
+ assert another_group .sources == group .sources
70
+ assert another_group .__traceback__ is group .__traceback__
71
+ assert another_group .__cause__ is group .__cause__
72
+ assert another_group .__context__ is group .__context__
73
+ assert another_group .__suppress_context__ is group .__suppress_context__
74
+ assert another_group .__cause__ is not None
75
+ assert another_group .__context__ is not None
76
+ assert another_group .__suppress_context__ is True
77
+
78
+ # doing copy when __suppress_context__ is False
65
79
group .__suppress_context__ = False
66
80
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__
81
+ assert another_group .__cause__ is group .__cause__
82
+ assert another_group .__context__ is group .__context__
83
+ assert another_group .__suppress_context__ is group .__suppress_context__
84
+ assert another_group .__suppress_context__ is False
0 commit comments