From da260c85cdb5df5e7ca37cc488febf3c6b88ac8c Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Fri, 11 Mar 2022 15:05:56 -0500 Subject: [PATCH] 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 --- tests/unit/test_network_connections.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_network_connections.py b/tests/unit/test_network_connections.py index 9bfa068..c1a4378 100644 --- a/tests/unit/test_network_connections.py +++ b/tests/unit/test_network_connections.py @@ -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(