Fixed #25183 -- Fixed non-deterministic GeoIP test.
google.com doesn't always resolve to an IP inside the United States.
This commit is contained in:
parent
35901e64b0
commit
5b6ca15073
|
@ -23,6 +23,8 @@ if HAS_GEOIP:
|
||||||
@skipUnless(HAS_GEOIP and getattr(settings, "GEOIP_PATH", None),
|
@skipUnless(HAS_GEOIP and getattr(settings, "GEOIP_PATH", None),
|
||||||
"GeoIP is required along with the GEOIP_PATH setting.")
|
"GeoIP is required along with the GEOIP_PATH setting.")
|
||||||
class GeoIPTest(unittest.TestCase):
|
class GeoIPTest(unittest.TestCase):
|
||||||
|
addr = '128.249.1.1'
|
||||||
|
fqdn = 'tmc.edu'
|
||||||
|
|
||||||
def test01_init(self):
|
def test01_init(self):
|
||||||
"Testing GeoIP initialization."
|
"Testing GeoIP initialization."
|
||||||
|
@ -68,10 +70,7 @@ class GeoIPTest(unittest.TestCase):
|
||||||
"Testing GeoIP country querying methods."
|
"Testing GeoIP country querying methods."
|
||||||
g = GeoIP(city='<foo>')
|
g = GeoIP(city='<foo>')
|
||||||
|
|
||||||
fqdn = 'www.google.com'
|
for query in (self.fqdn, self.addr):
|
||||||
addr = '12.215.42.19'
|
|
||||||
|
|
||||||
for query in (fqdn, addr):
|
|
||||||
for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name):
|
for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name):
|
||||||
self.assertEqual('US', func(query), 'Failed for func %s and query %s' % (func, query))
|
self.assertEqual('US', func(query), 'Failed for func %s and query %s' % (func, query))
|
||||||
for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name):
|
for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name):
|
||||||
|
@ -84,9 +83,7 @@ class GeoIPTest(unittest.TestCase):
|
||||||
"Testing GeoIP city querying methods."
|
"Testing GeoIP city querying methods."
|
||||||
g = GeoIP(country='<foo>')
|
g = GeoIP(country='<foo>')
|
||||||
|
|
||||||
addr = '128.249.1.1'
|
for query in (self.fqdn, self.addr):
|
||||||
fqdn = 'tmc.edu'
|
|
||||||
for query in (fqdn, addr):
|
|
||||||
# Country queries should still work.
|
# Country queries should still work.
|
||||||
for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name):
|
for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name):
|
||||||
self.assertEqual('US', func(query))
|
self.assertEqual('US', func(query))
|
||||||
|
|
Loading…
Reference in New Issue