diff options
| author | Claude Paroz <claude@2xlibre.net> | 2019-08-10 11:55:22 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-08-13 19:44:10 +0200 |
| commit | eed2e740f7efa9a9290fb913f796437e2c4adc5f (patch) | |
| tree | 9dd13dd5d3e7f6a53196b63c37c758eebaa55e70 /tests | |
| parent | 88c0b907e76bccfe1a25dc6580272b07aebd45d6 (diff) | |
Fixed #30461 -- Made GeoIP2 and GEOIP_PATH setting accept pathlib.Path as library path.
Thanks Nikita Krokosh for the initial patch.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/test_geoip2.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/gis_tests/test_geoip2.py b/tests/gis_tests/test_geoip2.py index 1fe3a1ebab..294d875ac8 100644 --- a/tests/gis_tests/test_geoip2.py +++ b/tests/gis_tests/test_geoip2.py @@ -1,4 +1,5 @@ import os +import pathlib from unittest import mock, skipUnless from django.conf import settings @@ -28,8 +29,13 @@ class GeoIPTest(SimpleTestCase): 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)) + else: + g4 = GeoIP2(str(path)) - for g in (g1, g2, g3): + for g in (g1, g2, g3, g4): self.assertTrue(g._country) self.assertTrue(g._city) |
