-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Labels
bugSomething isn't workingSomething isn't working
Description
A test for ipv4-mapped addresses fails on python 3.12 as IPv6Address.__str__ formats it in hex rather than as dotted-quad. See python/cpython@f22bf8e for the commit that changed this behaviour for python 3.13 onwards.
The test could be improved to work on 3.12 by using the ipv4_mapped property instead of relying on the stringification.
======================================================================
FAIL: test_round_trip_ipv4_mapped_address (tests.unit_tests.test_driver.test_network.TestIPv6DataType.test_round_trip_ipv4_mapped_address)
A full round-trip test to ensure serialization and deserialization work together.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/afs/inf.ed.ac.uk/user/b/bsmith5/chclient/clickhouse-connect/.pybuild/cpython3_3.12_clickhouse-connect/build/tests/unit_tests/test_driver/test_network.py", line 87, in test_round_trip_ipv4_mapped_address
self.assertEqual(str(final_ip), ip_string)
AssertionError: '::ffff:c0a8:101' != '::ffff:192.168.1.1'
- ::ffff:c0a8:101
+ ::ffff:192.168.1.1
----------------------------------------------------------------------
Ran 54 tests in 0.028s
FAILED (failures=1)
Example patch:
From: Benjamin Smith <[email protected]>
Date: Wed, 17 Sep 2025 10:45:36 +0100
Subject: Patch around a test for python 3.12
---
tests/unit_tests/test_driver/test_network.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/unit_tests/test_driver/test_network.py b/tests/unit_tests/test_driver/test_network.py
index 8fa4fbe..af740c5 100644
--- a/tests/unit_tests/test_driver/test_network.py
+++ b/tests/unit_tests/test_driver/test_network.py
@@ -84,7 +84,9 @@ class TestIPv6DataType(unittest.TestCase):
final_ip = read_result[0]
self.assertIsInstance(final_ip, IPv6Address)
- self.assertEqual(str(final_ip), ip_string)
+ # ipv4-mapped handling in IPv6Address.__str__ is a 3.13 feature
+ #self.assertEqual(str(final_ip), ip_string)
+ self.assertEqual('::ffff:' + str(final_ip.ipv4_mapped), ip_string)
def test_round_trip_standard_ipv6(self):
"""Ensures a standard IPv6 address can be written and read back correctly."""
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working