Skip to content

Commit

Permalink
Fix tests with Python 3.13
Browse files Browse the repository at this point in the history
The textual representation of addresses has changed, adapt the code to
expect different values on Python 3.13+.
See: python/cpython@f22bf8e3cf899896cf587099d292
  • Loading branch information
befeleme committed Apr 24, 2024
1 parent 829a7a2 commit 3b9aa7c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/test_ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from . import testutils
import unittest
import sys

import psycopg2
import psycopg2.extras
Expand Down Expand Up @@ -68,7 +69,12 @@ def test_inet_adapt(self):
self.assertEquals(cur.fetchone()[0], '127.0.0.1/24')

cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')])
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')

# The texual representation of addresses has changed in Python 3.13
if sys.version_info >= (3, 13):
self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128')
else:
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')

@testutils.skip_if_crdb("cidr")
def test_cidr_cast(self):
Expand Down Expand Up @@ -109,7 +115,12 @@ def test_cidr_adapt(self):
self.assertEquals(cur.fetchone()[0], '127.0.0.0/24')

cur.execute("select %s", [ip.ip_network('::ffff:102:300/128')])
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')

# The texual representation of addresses has changed in Python 3.13
if sys.version_info >= (3, 13):
self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128')
else:
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')


def test_suite():
Expand Down

0 comments on commit 3b9aa7c

Please sign in to comment.