• Kirill Smelkov's avatar
    golang: tests: Fix traceback tests for Python ≥ 3.10 · 53cd02b3
    Kirill Smelkov authored
    Python changed traceback output a bit:
    
    - added '^^^^^^^' and '~~^~~'
    - changed lineno of frame corresponding to __exit__ to be at line of `with ...`
    
    -> Adjust to that by introducing a bit more generalized conditionals in
       assertDoc.
    
    Here is, for example, how test_defer_excchain_traceback was failing on py3.11:
    
    E           Failed: not equal:
    E           Differences (unified diff with -expected +actual):
    E               @@ -1,6 +1,7 @@
    E                Traceback (most recent call last):
    E               -  File "PYGOLANG/golang/__init__.py", line ..., in _
    E               +  File "PYGOLANG/golang/__init__.py", line 103, in _
    E                    return f(*argv, **kw)
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in caller
    E               +           ^^^^^^^^^^^^^^
    E               +  File "PYGOLANG/golang/golang_test.py", line 1550, in caller
    E                    raise RuntimeError("ccc")
    E                RuntimeError: ccc
    E               @@ -9,7 +10,7 @@
    E                <BLANKLINE>
    E                Traceback (most recent call last):
    E               -  File "PYGOLANG/golang/__init__.py", line ..., in __exit__
    E               +  File "PYGOLANG/golang/__init__.py", line 180, in __exit__
    E                    d()
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in q2
    E               +  File "PYGOLANG/golang/golang_test.py", line 1548, in q2
    E                    raise RuntimeError("bbb")
    E                RuntimeError: bbb
    E               @@ -18,14 +19,16 @@
    E                <BLANKLINE>
    E                Traceback (most recent call last):
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in test_defer_excchain_traceback
    E               +  File "PYGOLANG/golang/golang_test.py", line 1553, in test_defer_excchain_traceback
    E                    caller()
    E               -  ...
    E               -  File "PYGOLANG/golang/__init__.py", line ..., in _
    E               -    return f(*argv, **kw)
    E               -  File "PYGOLANG/golang/__init__.py", line ..., in __exit__
    E               +  File "/home/kirr/src/tools/go/py3.venv/lib/python3.11/site-packages/decorator.py", line 232, in fun
    E               +    return caller(func, *(extras + args), **kw)
    E               +           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    E               +  File "PYGOLANG/golang/__init__.py", line 102, in _
    E               +    with __goframe__:
    E               +  File "PYGOLANG/golang/__init__.py", line 179, in __exit__
    E               +    with __goframe__:
    E               +  File "PYGOLANG/golang/__init__.py", line 180, in __exit__
    E                    d()
    E               -  File "PYGOLANG/golang/__init__.py", line ..., in __exit__
    E               -    d()
    E               -  File "PYGOLANG/golang/golang_test.py", line ..., in q1
    E               +  File "PYGOLANG/golang/golang_test.py", line 1545, in q1
    E                    raise RuntimeError("aaa")
    E                RuntimeError: aaa
    53cd02b3
golang_test.py 51.9 KB