Add 1000 random tests
This commit is contained in:
parent
bc9c8c3dcc
commit
96fb2c5a8e
|
@ -1,12 +1,17 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
from iptogeo import IPToGeo
|
import os
|
||||||
|
from iptogeo import IPToGeo, IPToGeoException
|
||||||
|
|
||||||
iptogeo = IPToGeo()
|
iptogeo = IPToGeo()
|
||||||
|
|
||||||
def test_ip(ip):
|
def test_ip(ip):
|
||||||
(ipres, country_code) = iptogeo.ip_to_geo(ip)
|
try:
|
||||||
|
(ipres, country_code) = iptogeo.ip_to_geo(ip)
|
||||||
|
except IPToGeoException, e:
|
||||||
|
print e
|
||||||
|
return
|
||||||
|
|
||||||
if not country_code:
|
if not country_code:
|
||||||
print 'Country code for %s (%08x) not found' % (ip, ipres)
|
print 'Country code for %s (%08x) not found' % (ip, ipres)
|
||||||
|
@ -22,3 +27,7 @@ test_ip('1.55.3.12')
|
||||||
test_ip('1.57.0.0')
|
test_ip('1.57.0.0')
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(0, 1000):
|
||||||
|
ip = '%d.%d.%d.%d' % \
|
||||||
|
(ord(os.urandom(1)), ord(os.urandom(1)), ord(os.urandom(1)), ord(os.urandom(1)))
|
||||||
|
test_ip(ip)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user