-
Kirill Smelkov authored
The code was crashing this way: ---- 8< ---- ====================================================================== ERROR: test_call_ipv6 (zodburi.tests.test_resolvers.TestClientStorageURIResolver) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched return func(*args, **keywargs) File "/home/kirr/src/wendelin/z/zodburi/zodburi/tests/test_resolvers.py", line 265, in test_call_ipv6 factory, dbkw = resolver('zeo://[::1]:9090?debug=true') File "/home/kirr/src/wendelin/z/zodburi/zodburi/resolvers.py", line 141, in __call__ host, port = netloc.split(':') ValueError: too many values to unpack ====================================================================== ERROR: test_call_ipv6_no_port (zodburi.tests.test_resolvers.TestClientStorageURIResolver) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched return func(*args, **keywargs) File "/home/kirr/src/wendelin/z/zodburi/zodburi/tests/test_resolvers.py", line 258, in test_call_ipv6_no_port factory, dbkw = resolver('zeo://[::1]?debug=true') File "/home/kirr/src/wendelin/z/zodburi/zodburi/resolvers.py", line 141, in __call__ host, port = netloc.split(':') ValueError: too many values to unpack ---- 8< ---- Fix it by leveraging the fact that urlparse.urlsplit return() tuple-like object with additional .hostname and .port attributes which already parse IPv6 correctly: In [2]: u = urlsplit('http://[::1]:5553') In [3]: u Out[3]: SplitResult(scheme='http', netloc='[::1]:5553', path='', query='', fragment='') In [4]: u.netloc Out[4]: '[::1]:5553' In [5]: u.hostname Out[5]: '::1' In [6]: u.port Out[6]: 5553 In [7]: u = urlsplit('http://[::1]') In [8]: u.hostname Out[8]: '::1' In [9]: u.port In [10]: repr(u.port) Out[10]: 'None'
696b84c4
To find the state of this project's repository at the time of any of these versions, check out
the tags.