Debian Codegraph @

ansible_collections/netapp/ontap/tests/unit/framework/ut_utilities.py

raw
1 # (c) 2022, NetApp, Inc
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # Author: Laurent Nicolas, [email protected]
4
5 """ unit tests for Ansible modules for ONTAP:
6 shared utility functions
7 """
8
9 from __future__ import (absolute_import, division, print_function)
10 __metaclass__ = type
11
12 import sys
13
14
15 def is_indexerror_exception_formatted():
16 """ some versions of python do not format IndexError exception properly
17 the error message is not reported in str() or repr()
18 We see this for older versions of Ansible, where the python version is frozen
19 - fails on 3.5.7 but works on 3.5.10
20 - fails on 3.6.8 but works on 3.6.9
21 - fails on 3.7.4 but works on 3.7.5
22 - fails on 3.8.0 but works on 3.8.1
23 """
24 return (
25 sys.version_info[:2] == (2, 7)
26 or (sys.version_info[:2] == (3, 5) and sys.version_info[:3] > (3, 5, 7))
27 or (sys.version_info[:2] == (3, 6) and sys.version_info[:3] > (3, 6, 8))
28 or (sys.version_info[:2] == (3, 7) and sys.version_info[:3] > (3, 7, 4))
29 or (sys.version_info[:2] == (3, 8) and sys.version_info[:3] > (3, 8, 0))
30 or sys.version_info[:2] >= (3, 9)
31 )