@@ -134,30 +134,28 @@ class Descriptor:
134134 def __set_name__ (self , owner , name ):
135135 1 / 0
136136
137- with self .assertRaises (RuntimeError ) as cm :
137+ with self .assertRaises (ZeroDivisionError ) as cm :
138138 class NotGoingToWork :
139139 attr = Descriptor ()
140140
141- exc = cm .exception
142- self .assertRegex (str (exc ), r'\bNotGoingToWork\b' )
143- self .assertRegex (str (exc ), r'\battr\b' )
144- self .assertRegex (str (exc ), r'\bDescriptor\b' )
145- self .assertIsInstance (exc .__cause__ , ZeroDivisionError )
141+ notes = cm .exception .__notes__
142+ self .assertRegex (str (notes ), r'\bNotGoingToWork\b' )
143+ self .assertRegex (str (notes ), r'\battr\b' )
144+ self .assertRegex (str (notes ), r'\bDescriptor\b' )
146145
147146 def test_set_name_wrong (self ):
148147 class Descriptor :
149148 def __set_name__ (self ):
150149 pass
151150
152- with self .assertRaises (RuntimeError ) as cm :
151+ with self .assertRaises (TypeError ) as cm :
153152 class NotGoingToWork :
154153 attr = Descriptor ()
155154
156- exc = cm .exception
157- self .assertRegex (str (exc ), r'\bNotGoingToWork\b' )
158- self .assertRegex (str (exc ), r'\battr\b' )
159- self .assertRegex (str (exc ), r'\bDescriptor\b' )
160- self .assertIsInstance (exc .__cause__ , TypeError )
155+ notes = cm .exception .__notes__
156+ self .assertRegex (str (notes ), r'\bNotGoingToWork\b' )
157+ self .assertRegex (str (notes ), r'\battr\b' )
158+ self .assertRegex (str (notes ), r'\bDescriptor\b' )
161159
162160 def test_set_name_lookup (self ):
163161 resolved = []
0 commit comments