@@ -162,32 +162,44 @@ class Descriptor:
162
162
def __set_name__ (self , owner , name ):
163
163
1 / ZERO
164
164
165
- with self .assertRaises (RuntimeError ) as cm :
165
+ with self .assertRaises (( RuntimeError , ZeroDivisionError ) ) as cm :
166
166
class NotGoingToWork :
167
167
attr = Descriptor ()
168
168
169
- exc = cm .exception
170
- self .assertRegex (str (exc ), r'\bNotGoingToWork\b' )
171
- self .assertRegex (str (exc ), r'\battr\b' )
172
- self .assertRegex (str (exc ), r'\bDescriptor\b' )
173
- if HAS_NATIVE_SUPPORT :
174
- self .assertIsInstance (exc .__cause__ , ZeroDivisionError )
169
+ if sys .version_info >= (3 , 12 ):
170
+ notes = cm .exception .__notes__
171
+ self .assertRegex (str (notes ), r'\bNotGoingToWork\b' )
172
+ self .assertRegex (str (notes ), r'\battr\b' )
173
+ self .assertRegex (str (notes ), r'\bDescriptor\b' )
174
+ else :
175
+ exc = cm .exception
176
+ self .assertRegex (str (exc ), r'\bNotGoingToWork\b' )
177
+ self .assertRegex (str (exc ), r'\battr\b' )
178
+ self .assertRegex (str (exc ), r'\bDescriptor\b' )
179
+ if HAS_NATIVE_SUPPORT :
180
+ self .assertIsInstance (exc .__cause__ , ZeroDivisionError )
175
181
176
182
def test_set_name_wrong (self ):
177
183
class Descriptor :
178
184
def __set_name__ (self ):
179
185
pass
180
186
181
- with self .assertRaises (RuntimeError ) as cm :
187
+ with self .assertRaises (( RuntimeError , TypeError ) ) as cm :
182
188
class NotGoingToWork :
183
189
attr = Descriptor ()
184
190
185
- exc = cm .exception
186
- self .assertRegex (str (exc ), r'\bNotGoingToWork\b' )
187
- self .assertRegex (str (exc ), r'\battr\b' )
188
- self .assertRegex (str (exc ), r'\bDescriptor\b' )
189
- if HAS_NATIVE_SUPPORT :
190
- self .assertIsInstance (exc .__cause__ , TypeError )
191
+ if sys .version_info >= (3 , 12 ):
192
+ notes = cm .exception .__notes__
193
+ self .assertRegex (str (notes ), r'\bNotGoingToWork\b' )
194
+ self .assertRegex (str (notes ), r'\battr\b' )
195
+ self .assertRegex (str (notes ), r'\bDescriptor\b' )
196
+ else :
197
+ exc = cm .exception
198
+ self .assertRegex (str (exc ), r'\bNotGoingToWork\b' )
199
+ self .assertRegex (str (exc ), r'\battr\b' )
200
+ self .assertRegex (str (exc ), r'\bDescriptor\b' )
201
+ if HAS_NATIVE_SUPPORT :
202
+ self .assertIsInstance (exc .__cause__ , TypeError )
191
203
192
204
def test_set_name_lookup (self ):
193
205
resolved = []
0 commit comments