diff --git a/tests/iptogeo.py b/tests/iptogeo.py index 8cecb19..80da04e 100644 --- a/tests/iptogeo.py +++ b/tests/iptogeo.py @@ -46,15 +46,16 @@ class IPToGeo(object): 5 : 'Unsupported IP version', 6 : 'IP not found'} - def __init__(self, remote_addr='127.0.0.1', remote_port=53333, timeout=None): + def __init__(self, remote_addr='127.0.0.1', remote_port=53333, timeout=None, family=socket.AF_INET): self._remote_addr = remote_addr self._remote_port = remote_port self._timeout = timeout - + self._family = family + self._create_socket() def _create_socket(self): - self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self._socket = socket.socket(self._family, socket.SOCK_STREAM) if not self._timeout is None: self._socket.settimeout(self._timeout) self._socket.connect((self._remote_addr, self._remote_port)) diff --git a/tests/test_ip_to_geo.py b/tests/test_ip_to_geo.py index abaf699..defd00a 100755 --- a/tests/test_ip_to_geo.py +++ b/tests/test_ip_to_geo.py @@ -2,12 +2,14 @@ # -*- coding: utf-8 import os +import sys +import socket from iptogeo import IPToGeo, IPToGeoException TIMEOUT = None # TIMEOUT = 5.0 -iptogeo = IPToGeo(timeout=TIMEOUT) +iptogeo = IPToGeo(timeout=TIMEOUT, family=socket.AF_INET6, remote_addr='::1') def get_random_ip_v4(): ip = '%d.%d.%d.%d' % \