@@ -665,6 +665,26 @@ def exc(ex):
665
665
self .assertMatchesTemplate (
666
666
rest , ExceptionGroup , [ValueError (1 )])
667
667
668
+ def test_split_copies_notes (self ):
669
+ # make sure each exception group after a split has its own __notes__ list
670
+ eg = ExceptionGroup ("eg" , [ValueError (1 ), TypeError (2 )])
671
+ eg .add_note ("note1" )
672
+ eg .add_note ("note2" )
673
+ orig_notes = list (eg .__notes__ )
674
+ match , rest = eg .split (TypeError )
675
+ self .assertEqual (eg .__notes__ , orig_notes )
676
+ self .assertEqual (match .__notes__ , orig_notes )
677
+ self .assertEqual (rest .__notes__ , orig_notes )
678
+ self .assertIsNot (eg .__notes__ , match .__notes__ )
679
+ self .assertIsNot (eg .__notes__ , rest .__notes__ )
680
+ self .assertIsNot (match .__notes__ , rest .__notes__ )
681
+ eg .add_note ("eg" )
682
+ match .add_note ("match" )
683
+ rest .add_note ("rest" )
684
+ self .assertEqual (eg .__notes__ , orig_notes + ["eg" ])
685
+ self .assertEqual (match .__notes__ , orig_notes + ["match" ])
686
+ self .assertEqual (rest .__notes__ , orig_notes + ["rest" ])
687
+
668
688
669
689
class NestedExceptionGroupSubclassSplitTest (ExceptionGroupSplitTestBase ):
670
690
0 commit comments