diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2021-04-05 01:24:52 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-12-05 08:21:19 +0100 |
| commit | 07f9f9960c477c7f60a5f3f243a0f404a56b1121 (patch) | |
| tree | f02201070b37ef451994746b85ceabcd9888c3e9 /tests | |
| parent | 464af0975cac6abc46b3e5c3305194c958fc465b (diff) | |
Deprecated django.contrib.gis.geoip2.GeoIP2.open().
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/test_geoip2.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/gis_tests/test_geoip2.py b/tests/gis_tests/test_geoip2.py index 53f2b20bbc..acdfde9ec7 100644 --- a/tests/gis_tests/test_geoip2.py +++ b/tests/gis_tests/test_geoip2.py @@ -29,14 +29,13 @@ class GeoIPTest(SimpleTestCase): g1 = GeoIP2() # Everything inferred from GeoIP path path = settings.GEOIP_PATH g2 = GeoIP2(path, 0) # Passing in data path explicitly. - g3 = GeoIP2.open(path, 0) # MaxMind Python API syntax. # path accepts str and pathlib.Path. if isinstance(path, str): - g4 = GeoIP2(pathlib.Path(path)) + g3 = GeoIP2(pathlib.Path(path)) else: - g4 = GeoIP2(str(path)) + g3 = GeoIP2(str(path)) - for g in (g1, g2, g3, g4): + for g in (g1, g2, g3): self.assertTrue(g._country) self.assertTrue(g._city) @@ -198,3 +197,10 @@ class GeoIPTest(SimpleTestCase): e1, e2 = g.coords(self.fqdn) self.assertIsInstance(e1, float) self.assertIsInstance(e2, float) + + def test_open_deprecation_warning(self): + msg = "GeoIP2.open() is deprecated. Use GeoIP2() instead." + with self.assertWarnsMessage(RemovedInDjango60Warning, msg): + g = GeoIP2.open(settings.GEOIP_PATH, 0) + self.assertTrue(g._country) + self.assertTrue(g._city) |
