From 236c52b7127993d6e61654b97520e0c577144d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Wed, 1 Oct 2025 22:52:42 -0600 Subject: [PATCH] test: adapt to interface representations in different Python versions Is 3.12.10 (or lower) being used by the runner? Fix version ranges Condition expected value based on observed Python behaviour Co-authored-by: Daniele Varrazzo --- tests/test_ipaddress.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_ipaddress.py b/tests/test_ipaddress.py index 3f803690..9f0c308f 100755 --- a/tests/test_ipaddress.py +++ b/tests/test_ipaddress.py @@ -71,10 +71,13 @@ class NetworkingTestCase(testutils.ConnectingTestCase): cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')]) # The texual representation of addresses has changed in Python 3.13 - if sys.version_info >= (3, 13): + # https://github.com/python/cpython/issues/128840 + if str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:1.2.3.0/128": self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128') - else: + elif str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:102:300/128": self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') + else: + assert False, "unexpected" @testutils.skip_if_crdb("cidr") def test_cidr_cast(self): @@ -117,10 +120,13 @@ class NetworkingTestCase(testutils.ConnectingTestCase): cur.execute("select %s", [ip.ip_network('::ffff:102:300/128')]) # The texual representation of addresses has changed in Python 3.13 - if sys.version_info >= (3, 13): + # https://github.com/python/cpython/issues/128840 + if str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:1.2.3.0/128": self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128') - else: + elif str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:102:300/128": self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') + else: + assert False, "unexpected" def test_suite():