@@ -1411,7 +1411,7 @@ def h():
1411
1411
assert line .endswith ("mod.py" )
1412
1412
assert tw_mock .lines [48 ] == ":15: AttributeError"
1413
1413
else :
1414
- assert tw_mock .lines [43 ] == "> raise AttributeError()"
1414
+ assert tw_mock .lines [43 ] == "> if True: raise AttributeError()"
1415
1415
assert tw_mock .lines [44 ] == "E AttributeError"
1416
1416
assert tw_mock .lines [45 ] == ""
1417
1417
line = tw_mock .get_write_msg (46 )
@@ -1535,24 +1535,44 @@ def unreraise():
1535
1535
r = excinfo .getrepr (style = "short" )
1536
1536
r .toterminal (tw_mock )
1537
1537
out = "\n " .join (line for line in tw_mock .lines if isinstance (line , str ))
1538
- expected_out = textwrap .dedent (
1539
- """\
1540
- :13: in unreraise
1541
- reraise()
1542
- :10: in reraise
1543
- raise Err() from e
1544
- E test_exc_chain_repr_cycle0.mod.Err
1545
-
1546
- During handling of the above exception, another exception occurred:
1547
- :15: in unreraise
1548
- raise e.__cause__
1549
- :8: in reraise
1550
- fail()
1551
- :5: in fail
1552
- return 0 / 0
1553
- ^^^^^
1554
- E ZeroDivisionError: division by zero"""
1555
- )
1538
+ # Assert highlighting carets in python3.11+
1539
+ if sys .version_info >= (3 , 11 ):
1540
+ expected_out = textwrap .dedent (
1541
+ """\
1542
+ :13: in unreraise
1543
+ reraise()
1544
+ :10: in reraise
1545
+ raise Err() from e
1546
+ E test_exc_chain_repr_cycle0.mod.Err
1547
+
1548
+ During handling of the above exception, another exception occurred:
1549
+ :15: in unreraise
1550
+ raise e.__cause__
1551
+ :8: in reraise
1552
+ fail()
1553
+ :5: in fail
1554
+ return 0 / 0
1555
+ ^^^^^
1556
+ E ZeroDivisionError: division by zero"""
1557
+ )
1558
+ else :
1559
+ expected_out = textwrap .dedent (
1560
+ """\
1561
+ :13: in unreraise
1562
+ reraise()
1563
+ :10: in reraise
1564
+ raise Err() from e
1565
+ E test_exc_chain_repr_cycle0.mod.Err
1566
+
1567
+ During handling of the above exception, another exception occurred:
1568
+ :15: in unreraise
1569
+ raise e.__cause__
1570
+ :8: in reraise
1571
+ fail()
1572
+ :5: in fail
1573
+ return 0 / 0
1574
+ E ZeroDivisionError: division by zero"""
1575
+ )
1556
1576
assert out == expected_out
1557
1577
1558
1578
def test_exec_type_error_filter (self , importasmod ):
0 commit comments