• Kirill Smelkov's avatar
    golang: Fix defer traceback tests when run somewhere under symlink · 7faaecbc
    Kirill Smelkov authored
    Since realpath was used to find out pygolang dir, it will give different
    prefix compared to what actual prefix of __file__ is if __file__ was
    imported through some symlinked directory. And it is the actual
    __file__ that is included into traceback - not its realpath'ed version.
    
    This was breaking for example like this on py27-gevent tox tests:
    
        __file__:          '.../pygolang/.tox/py27-gevent/local/lib/python2.7/site-packages/golang/golang_test.py'
        dirname(__file__): '.../pygolang/.tox/py27-gevent/local/lib/python2.7/site-packages/golang'
        PYGOLANG:          '.../pygolang/.tox/py27-gevent/lib/python2.7/site-packages'
    
        E           Failed: not equal:
        E           Differences (unified diff with -expected +actual):
        E               @@ -1,8 +1,8 @@
        E                Traceback (most recent call last):
        E               -  File "PYGOLANG/golang/golang_test.py", line ..., in test_defer_excchain_traceback
        E               +  File ".../pygolang/.tox/py27-gevent/local/lib/python2.7/site-packages/golang/golang_test.py", line 1360, in test_defer_excchain_traceback
        E                    alpha()
        E               -  File "PYGOLANG/golang/golang_test.py", line ..., in alpha
        E               +  File ".../pygolang/.tox/py27-gevent/local/lib/python2.7/site-packages/golang/golang_test.py", line 1357, in alpha
        E                    beta()
        E               -  File "PYGOLANG/golang/golang_test.py", line ..., in beta
        E               +  File ".../pygolang/.tox/py27-gevent/local/lib/python2.7/site-packages/golang/golang_test.py", line 1356, in beta
        E                    raise RuntimeError("gamma")
        E                RuntimeError: gamma
    
    -> Fix it by not doing realpath'ification when detecting PYGOLANG
    prefix.
    
    Fixes: bb9a94c3 (golang: Teach defer to chain exceptions (PEP 3134) even on Python2)
    7faaecbc
golang_test.py 42.7 KB