From 77566dcc6e489de9f711498b3d5c9018b50be176 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 30 Jul 2015 12:16:14 -0400 Subject: [PATCH] [1.8.x] Fixed #25183 -- Fixed non-deterministic GeoIP test. google.com doesn't always resolve to an IP inside the United States. Backport of 5b6ca150730cddb09ff8622d49b273d57b9c6703 from master --- tests/gis_tests/test_geoip.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/gis_tests/test_geoip.py b/tests/gis_tests/test_geoip.py index 3262b8c3c5..908b497962 100644 --- a/tests/gis_tests/test_geoip.py +++ b/tests/gis_tests/test_geoip.py @@ -26,6 +26,8 @@ if HAS_GEOS: @skipUnless(HAS_GEOIP and getattr(settings, "GEOIP_PATH", None), "GeoIP is required along with the GEOIP_PATH setting.") class GeoIPTest(unittest.TestCase): + addr = '128.249.1.1' + fqdn = 'tmc.edu' def test01_init(self): "Testing GeoIP initialization." @@ -71,10 +73,7 @@ class GeoIPTest(unittest.TestCase): "Testing GeoIP country querying methods." g = GeoIP(city='') - fqdn = 'www.google.com' - addr = '12.215.42.19' - - for query in (fqdn, addr): + for query in (self.fqdn, self.addr): for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name): self.assertEqual('US', func(query)) for func in (g.country_name, g.country_name_by_addr, g.country_name_by_name): @@ -87,9 +86,7 @@ class GeoIPTest(unittest.TestCase): "Testing GeoIP city querying methods." g = GeoIP(country='') - addr = '128.249.1.1' - fqdn = 'tmc.edu' - for query in (fqdn, addr): + for query in (self.fqdn, self.addr): # Country queries should still work. for func in (g.country_code, g.country_code_by_addr, g.country_code_by_name): self.assertEqual('US', func(query))