@@ -1001,44 +1001,54 @@ def h():
1001
1001
assert tw .lines [2 ] == " try:"
1002
1002
assert tw .lines [3 ] == "> g()"
1003
1003
assert tw .lines [4 ] == ""
1004
- assert tw .lines [5 ].endswith ("mod.py:6: " )
1005
- assert tw .lines [6 ] == ("_ " , None )
1006
- assert tw .lines [7 ] == ""
1007
- assert tw .lines [8 ] == " def g():"
1008
- assert tw .lines [9 ] == "> raise ValueError()"
1009
- assert tw .lines [10 ] == "E ValueError"
1010
- assert tw .lines [11 ] == ""
1011
- assert tw .lines [12 ].endswith ("mod.py:12: ValueError" )
1012
- assert tw .lines [13 ] == ""
1013
- assert tw .lines [14 ] == "The above exception was the direct cause of the following exception:"
1004
+ line = tw .get_write_msg (5 )
1005
+ assert line .endswith ('mod.py' )
1006
+ assert tw .lines [6 ] == ':6: '
1007
+ assert tw .lines [7 ] == ("_ " , None )
1008
+ assert tw .lines [8 ] == ""
1009
+ assert tw .lines [9 ] == " def g():"
1010
+ assert tw .lines [10 ] == "> raise ValueError()"
1011
+ assert tw .lines [11 ] == "E ValueError"
1012
+ assert tw .lines [12 ] == ""
1013
+ line = tw .get_write_msg (13 )
1014
+ assert line .endswith ('mod.py' )
1015
+ assert tw .lines [14 ] == ':12: ValueError'
1014
1016
assert tw .lines [15 ] == ""
1015
- assert tw .lines [16 ] == " def f() :"
1016
- assert tw .lines [17 ] == " try: "
1017
- assert tw .lines [18 ] == " g() "
1018
- assert tw .lines [19 ] == " except Exception as e :"
1019
- assert tw .lines [20 ] == "> raise Err() from e "
1020
- assert tw .lines [21 ] == "E test_exc_chain_repr0.mod.Err "
1021
- assert tw .lines [22 ] == ""
1022
- assert tw .lines [23 ]. endswith ( " mod.py:8: Err")
1017
+ assert tw .lines [16 ] == "The above exception was the direct cause of the following exception :"
1018
+ assert tw .lines [17 ] == ""
1019
+ assert tw .lines [18 ] == " def f(): "
1020
+ assert tw .lines [19 ] == " try :"
1021
+ assert tw .lines [20 ] == " g() "
1022
+ assert tw .lines [21 ] == " except Exception as e: "
1023
+ assert tw .lines [22 ] == "> raise Err() from e "
1024
+ assert tw .lines [23 ] == "E test_exc_chain_repr0. mod.Err"
1023
1025
assert tw .lines [24 ] == ""
1024
- assert tw .lines [25 ] == "During handling of the above exception, another exception occurred:"
1025
- assert tw .lines [26 ] == ""
1026
- assert tw .lines [27 ] == " def f():"
1027
- assert tw .lines [28 ] == " try:"
1028
- assert tw .lines [29 ] == " g()"
1029
- assert tw .lines [30 ] == " except Exception as e:"
1030
- assert tw .lines [31 ] == " raise Err() from e"
1031
- assert tw .lines [32 ] == " finally:"
1032
- assert tw .lines [33 ] == "> h()"
1033
- assert tw .lines [34 ] == ""
1034
- assert tw .lines [35 ].endswith ("mod.py:10: " )
1035
- assert tw .lines [36 ] == ('_ ' , None )
1026
+ line = tw .get_write_msg (25 )
1027
+ assert line .endswith ('mod.py' )
1028
+ assert tw .lines [26 ] == ":8: Err"
1029
+ assert tw .lines [27 ] == ""
1030
+ assert tw .lines [28 ] == "During handling of the above exception, another exception occurred:"
1031
+ assert tw .lines [29 ] == ""
1032
+ assert tw .lines [30 ] == " def f():"
1033
+ assert tw .lines [31 ] == " try:"
1034
+ assert tw .lines [32 ] == " g()"
1035
+ assert tw .lines [33 ] == " except Exception as e:"
1036
+ assert tw .lines [34 ] == " raise Err() from e"
1037
+ assert tw .lines [35 ] == " finally:"
1038
+ assert tw .lines [36 ] == "> h()"
1036
1039
assert tw .lines [37 ] == ""
1037
- assert tw .lines [38 ] == " def h():"
1038
- assert tw .lines [39 ] == "> raise AttributeError()"
1039
- assert tw .lines [40 ] == "E AttributeError"
1040
+ line = tw .get_write_msg (38 )
1041
+ assert line .endswith ('mod.py' )
1042
+ assert tw .lines [39 ] == ":10: "
1043
+ assert tw .lines [40 ] == ('_ ' , None )
1040
1044
assert tw .lines [41 ] == ""
1041
- assert tw .lines [42 ].endswith ("mod.py:15: AttributeError" )
1045
+ assert tw .lines [42 ] == " def h():"
1046
+ assert tw .lines [43 ] == "> raise AttributeError()"
1047
+ assert tw .lines [44 ] == "E AttributeError"
1048
+ assert tw .lines [45 ] == ""
1049
+ line = tw .get_write_msg (46 )
1050
+ assert line .endswith ('mod.py' )
1051
+ assert tw .lines [47 ] == ":15: AttributeError"
1042
1052
1043
1053
1044
1054
@pytest .mark .parametrize ("style" , ["short" , "long" ])
0 commit comments