Commit 74a9838c authored by Kirill Smelkov's avatar Kirill Smelkov

golang: tests: Fix for Pytest ≥ 7.4

Pytest 7.4 changed format of output tracebacks. Similarly to IPython adding
test support for later versions would add maintenance cost on pygolang
side, but testing this is actually not needed, since we activate
Pytest-related patch only on py2 and for py2 the latest pytest version
is pytest 4.6.11.

-> So simply skip this test if we see we have Pytest ≥ 7.4.
   Skip it only on py3 just in case.

For the reference here is how diff in between running
golang_test_defer_excchain.py on Pytest 7.3 and Pytest 7.4 looks:

    diff --git a/a b/b
    index 45680b99..47c29cea 100644
    --- a/a
    +++ b/b
    @@ -1,5 +1,5 @@
     ============================= test session starts ==============================
    -platform linux -- Python 3.12.2+, pytest-7.3.2, pluggy-1.4.0
    +platform linux -- Python 3.12.2+, pytest-7.4.0, pluggy-1.4.0
     rootdir: /home/kirr/src/tools/go/pygolang-master
     collected 1 item

    @@ -7,22 +7,16 @@ golang/testprog/golang_test_defer_excchain.py F                          [100%]

     =================================== FAILURES ===================================
     _____________________________________ main _____________________________________
    -golang/__init__.py:106: in _
    -    return f(*argv, **kw)
     golang/testprog/golang_test_defer_excchain.py:42: in main
         raise RuntimeError("err")
     E   RuntimeError: err

     During handling of the above exception, another exception occurred:
    -golang/__init__.py:183: in __exit__
    -    d()
     golang/testprog/golang_test_defer_excchain.py:31: in d1
         raise RuntimeError("d1: aaa")
     E   RuntimeError: d1: aaa

     During handling of the above exception, another exception occurred:
    -golang/__init__.py:183: in __exit__
    -    d()
     golang/testprog/golang_test_defer_excchain.py:33: in d2
         1/0
     E   ZeroDivisionError: division by zero

/reviewed-by @jerome
/reviewed-on nexedi/pygolang!23
parent 68f384a9
......@@ -1682,6 +1682,12 @@ def test_defer_excchain_dump_ipython():
# ----//---- (pytest)
def test_defer_excchain_dump_pytest():
# pytest 7.4 also changed traceback output format
# similarly to ipython we do not need to test it becase we activate
# pytest-related patch only on py2 for which latest pytest version is 4.6.11 .
import pytest
if six.PY3 and pytest.version_tuple >= (7,4):
skip("pytest is patched only on py2; pytest7.4 changed traceback format")
tbok = readfile(dir_testprog + "/golang_test_defer_excchain.txt-pytest")
retcode, stdout, stderr = _pyrun([
# don't let pytest emit internal deprecation warnings to stderr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment