mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 18:35:13 +00:00
fix: class Python26CompatTestCase broken by minor python versions
Extract the version of Python interpreter using the `sys.version` will break the Python26CompatTestCase class when the Python version is 3.11. Rather the correct way to compare the Python version is using the `sys.version_info` or the `platform` module as suggested in Python official doc, https://docs.python.org/3/library/sys.html#sys.version. Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
8b8492eac6
commit
da260c85cd
1 changed files with 2 additions and 2 deletions
|
|
@ -58,9 +58,9 @@ def pprint(msg, obj):
|
|||
class Python26CompatTestCase(unittest.TestCase):
|
||||
# pylint: disable=no-member
|
||||
def assertRaisesRegex(self, exception, regex, *args, **kwargs):
|
||||
if sys.version[:3] == "2.6":
|
||||
if sys.version_info[:2] == (2, 6):
|
||||
self.assertRaises(exception, *args, **kwargs)
|
||||
elif sys.version[:3] < "3.2":
|
||||
elif sys.version_info[:2] < (3, 2):
|
||||
self.assertRaisesRegexp(exception, regex, *args, **kwargs)
|
||||
else:
|
||||
super(Python26CompatTestCase, self).assertRaisesRegex(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue