@@ -288,8 +288,8 @@ def __str__(self):
288
288
"exc_type, exc_value, expected_what" ,
289
289
(
290
290
(ValueError , "plain_str" , "ValueError: plain_str" ),
291
- (ValueError , ("tuple_elem" ,), "ValueError: (' tuple_elem',) " ),
292
- (FlakyException , ("happy" ,), "FlakyException: ('happy',) " ),
291
+ (ValueError , ("tuple_elem" ,), "ValueError: tuple_elem" ),
292
+ (FlakyException , ("happy" ,), "FlakyException: FlakyException.__str__ " ),
293
293
),
294
294
)
295
295
def test_error_already_set_what_with_happy_exceptions (
@@ -307,17 +307,15 @@ def test_flaky_exception_failure_point_init():
307
307
assert not py_err_set_after_what
308
308
lines = what .splitlines ()
309
309
# PyErr_NormalizeException replaces the original FlakyException with ValueError:
310
- assert lines [:3 ] == ["FlakyException: ('failure_point_init',)" , "" , "At:" ]
311
- # Checking the first two lines of the traceback as formatted in error_string(),
312
- # which is actually for a different exception (ValueError)!
310
+ assert lines [:3 ] == ["ValueError: triggered_failure_point_init" , "" , "At:" ]
311
+ # Checking the first two lines of the traceback as formatted in error_string():
313
312
assert "test_exceptions.py(" in lines [3 ]
314
313
assert lines [3 ].endswith ("): __init__" )
315
314
assert lines [4 ].endswith ("): test_flaky_exception_failure_point_init" )
316
315
317
316
318
317
def test_flaky_exception_failure_point_str ():
319
- what , py_err_set_after_what = m .error_already_set_what (
320
- FlakyException , ("failure_point_str" ,)
321
- )
322
- assert not py_err_set_after_what
323
- assert what == "FlakyException: ('failure_point_str',)"
318
+ # The error_already_set ctor fails due to a ValueError in error_string():
319
+ with pytest .raises (ValueError ) as excinfo :
320
+ m .error_already_set_what (FlakyException , ("failure_point_str" ,))
321
+ assert str (excinfo .value ) == "triggered_failure_point_str"
0 commit comments