Skip to content

golang: test: Fix for Pytest < 7

Kirill Smelkov requested to merge kirr/pygolang:y/fix-pytest-old into master

In 74a9838c (golang: tests: Fix for Pytest ≥ 7.4) I fixed test_defer_excchain_dump_pytest for Pytest ≥ 7.4 but missed that pytest.version_tuple is not available for Pytest < 7.0(*) which started to lead to pygolang test failures on py3 under SlapOS becuase there we are still using pytest 4.6.11 :

_______________________ test_defer_excchain_dump_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):
E       AttributeError: module 'pytest' has no attribute 'version_tuple'

https://stack.nexedi.com/test_result_module/20240920-666C5CF1/3

-> Fix that by checking pytest.version_tuple more carefully.

(*) see https://docs.pytest.org/en/stable/reference/reference.html#pytest-version-tuple

/cc @jerome

Merge request reports