diff options
| author | Nick Pope <nick@nickpope.me.uk> | 2023-12-01 12:55:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-01 13:55:45 +0100 |
| commit | 0f83133a35088f6bbbce11ea8256168782860932 (patch) | |
| tree | 9b45170474b878a6e19aaf54af1d2db2cc45f4ae /tests/gis_tests | |
| parent | 79099a7ba454581ab521fcb4ea61fc6ed3dccf26 (diff) | |
Made GeoIP2.__del__() close all databases.
Diffstat (limited to 'tests/gis_tests')
| -rw-r--r-- | tests/gis_tests/test_geoip2.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/gis_tests/test_geoip2.py b/tests/gis_tests/test_geoip2.py index 1a8773a6d7..53f2b20bbc 100644 --- a/tests/gis_tests/test_geoip2.py +++ b/tests/gis_tests/test_geoip2.py @@ -152,6 +152,16 @@ class GeoIPTest(SimpleTestCase): self.assertEqual("Lawrence", d["city"]) self.assertEqual("KS", d["region"]) + def test_del(self): + g = GeoIP2() + city = g._city + country = g._country + self.assertIs(city._db_reader.closed, False) + self.assertIs(country._db_reader.closed, False) + del g + self.assertIs(city._db_reader.closed, True) + self.assertIs(country._db_reader.closed, True) + def test_repr(self): path = settings.GEOIP_PATH g = GeoIP2(path=path) |
