Skip to content

Commit 236c52b

Browse files
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 <daniele.varrazzo@gmail.com>
1 parent e0507a8 commit 236c52b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/test_ipaddress.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,13 @@ def test_inet_adapt(self):
7171
cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')])
7272

7373
# The texual representation of addresses has changed in Python 3.13
74-
if sys.version_info >= (3, 13):
74+
# https://github.com/python/cpython/issues/128840
75+
if str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:1.2.3.0/128":
7576
self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128')
76-
else:
77+
elif str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:102:300/128":
7778
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
79+
else:
80+
assert False, "unexpected"
7881

7982
@testutils.skip_if_crdb("cidr")
8083
def test_cidr_cast(self):
@@ -117,10 +120,13 @@ def test_cidr_adapt(self):
117120
cur.execute("select %s", [ip.ip_network('::ffff:102:300/128')])
118121

119122
# The texual representation of addresses has changed in Python 3.13
120-
if sys.version_info >= (3, 13):
123+
# https://github.com/python/cpython/issues/128840
124+
if str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:1.2.3.0/128":
121125
self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128')
122-
else:
126+
elif str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:102:300/128":
123127
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
128+
else:
129+
assert False, "unexpected"
124130

125131

126132
def test_suite():

0 commit comments

Comments
 (0)