• Kirill Smelkov's avatar
    golang: tests: Fix for IPython ≥ 8 · dfe75e9a
    Kirill Smelkov authored
    IPython8 changed format of output tracebacks (see
    https://github.com/ipython/ipython/commit/02660f35 and further). Adding
    test support for later versions would add maintenance cost on pygolang
    side, but testing this is actually not needed, since we activate
    IPython-related patch only on py2 and for py2 the latest ipython version
    is ipython5.
    
    -> So simply skip this test if we see we have IPython ≥ 8.
       Skip it only on py3 just in case.
    
    For the reference here is how diff in between running
    golang_test_defer_excchain.py on IPython7 and IPython8 looks:
    
        diff --git a/golang/testprog/7 b/golang/testprog/8
        index 5c31ed2..8fea57b 100644
        --- a/golang/testprog/7
        +++ b/golang/testprog/8
        @@ -1,101 +1,91 @@
        -[22;0t]0;IPython: golang/testprog---------------------------------------------------------------------------
        +---------------------------------------------------------------------------
         RuntimeError                              Traceback (most recent call last)
        -~/src/tools/go/pygolang-master/golang/__init__.py in _(f, *argv, **kw)
        -    102         with __goframe__:
        ---> 103             return f(*argv, **kw)
        -    104
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:103, in _func.<locals>._(f, *argv, **kw)
        +    102 with __goframe__:
        +--> 103     return f(*argv, **kw)
    
        -~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py in main()
        -     41     defer(d1)
        ----> 42     raise RuntimeError("err")
        -     43
        +File ~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py:42, in main()
        +     41 defer(d1)
        +---> 42 raise RuntimeError("err")
    
         RuntimeError: err
    
         During handling of the above exception, another exception occurred:
    
         RuntimeError                              Traceback (most recent call last)
        -~/src/tools/go/pygolang-master/golang/__init__.py in __exit__(__goframe__, exc_type, exc_val, exc_tb)
        -    179             with __goframe__:
        ---> 180                 d()
        -    181
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:180, in _GoFrame.__exit__(__goframe__, exc_type, exc_val, exc_tb)
        +    179     with __goframe__:
        +--> 180         d()
        +    182 return __goframe__.recovered
    
        -~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py in d1()
        +File ~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py:31, in d1()
              30 def d1():
         ---> 31     raise RuntimeError("d1: aaa")
        -     32 def d2():
    
         RuntimeError: d1: aaa
    
         During handling of the above exception, another exception occurred:
    
         ZeroDivisionError                         Traceback (most recent call last)
        -~/src/tools/go/pygolang-master/golang/__init__.py in __exit__(__goframe__, exc_type, exc_val, exc_tb)
        -    179             with __goframe__:
        ---> 180                 d()
        -    181
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:180, in _GoFrame.__exit__(__goframe__, exc_type, exc_val, exc_tb)
        +    179     with __goframe__:
        +--> 180         d()
        +    182 return __goframe__.recovered
    
        -~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py in d2()
        +File ~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py:33, in d2()
              32 def d2():
         ---> 33     1/0
        -     34 def d3():
    
         ZeroDivisionError: division by zero
    
         During handling of the above exception, another exception occurred:
    
         RuntimeError                              Traceback (most recent call last)
        -/usr/lib/python3.11/runpy.py in run_module(mod_name, init_globals, run_name, alter_sys)
        +File <frozen runpy>:226, in run_module(mod_name, init_globals, run_name, alter_sys)
    
        -/usr/lib/python3.11/runpy.py in _run_module_code(code, init_globals, mod_name, mod_spec, pkg_name, script_name)
        +File <frozen runpy>:98, in _run_module_code(code, init_globals, mod_name, mod_spec, pkg_name, script_name)
    
        -/usr/lib/python3.11/runpy.py in _run_code(code, run_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
        +File <frozen runpy>:88, in _run_code(code, run_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
    
        -~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py in <module>
        -     43
        +File ~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py:45
        +     42     raise RuntimeError("err")
              44 if __name__ == "__main__":
         ---> 45     main()
    
        -~/src/tools/go/py3.venv/lib/python3.11/site-packages/decorator.py in fun(*args, **kw)
        -    230             if not kwsyntax:
        -    231                 args, kw = fix(args, kw, sig)
        ---> 232             return caller(func, *(extras + args), **kw)
        -    233     fun.__name__ = func.__name__
        -    234     fun.__doc__ = func.__doc__
        +File ~/src/tools/go/py3.venv/lib/python3.11/site-packages/decorator.py:232, in decorate.<locals>.fun(*args, **kw)
        +    230 if not kwsyntax:
        +    231     args, kw = fix(args, kw, sig)
        +--> 232 return caller(func, *(extras + args), **kw)
    
        -~/src/tools/go/pygolang-master/golang/__init__.py in _(f, *argv, **kw)
        -    100         # run f under separate frame, where defer will register calls.
        -    101         __goframe__ = _GoFrame()
        ---> 102         with __goframe__:
        -    103             return f(*argv, **kw)
        -    104
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:102, in _func.<locals>._(f, *argv, **kw)
        +     99 def _(f, *argv, **kw):
        +    100     # run f under separate frame, where defer will register calls.
        +    101     __goframe__ = _GoFrame()
        +--> 102     with __goframe__:
        +    103         return f(*argv, **kw)
    
        -~/src/tools/go/pygolang-master/golang/__init__.py in __exit__(__goframe__, exc_type, exc_val, exc_tb)
        -    177
        -    178             # even if d panics - we have to call other defers
        ---> 179             with __goframe__:
        -    180                 d()
        -    181
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:179, in _GoFrame.__exit__(__goframe__, exc_type, exc_val, exc_tb)
        +    176     d = __goframe__.deferv.pop()
        +    178     # even if d panics - we have to call other defers
        +--> 179     with __goframe__:
        +    180         d()
        +    182 return __goframe__.recovered
    
        -~/src/tools/go/pygolang-master/golang/__init__.py in __exit__(__goframe__, exc_type, exc_val, exc_tb)
        -    177
        -    178             # even if d panics - we have to call other defers
        ---> 179             with __goframe__:
        -    180                 d()
        -    181
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:179, in _GoFrame.__exit__(__goframe__, exc_type, exc_val, exc_tb)
        +    176     d = __goframe__.deferv.pop()
        +    178     # even if d panics - we have to call other defers
        +--> 179     with __goframe__:
        +    180         d()
        +    182 return __goframe__.recovered
    
        -~/src/tools/go/pygolang-master/golang/__init__.py in __exit__(__goframe__, exc_type, exc_val, exc_tb)
        -    178             # even if d panics - we have to call other defers
        -    179             with __goframe__:
        ---> 180                 d()
        -    181
        -    182         return __goframe__.recovered
        +File ~/src/tools/go/pygolang-master/golang/__init__.py:180, in _GoFrame.__exit__(__goframe__, exc_type, exc_val, exc_tb)
        +    178     # even if d panics - we have to call other defers
        +    179     with __goframe__:
        +--> 180         d()
        +    182 return __goframe__.recovered
    
        -~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py in d3()
        -     33     1/0
        +File ~/src/tools/go/pygolang-master/golang/testprog/golang_test_defer_excchain.py:35, in d3()
              34 def d3():
         ---> 35     raise RuntimeError("d3: bbb")
        -     36
        -     37 @func
    
         RuntimeError: d3: bbb
    dfe75e9a
golang_test.py 50.4 KB