1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Made GeoIP2.__del__() close all databases.

This commit is contained in:
Nick Pope
2023-12-01 12:55:45 +00:00
committed by GitHub
parent 79099a7ba4
commit 0f83133a35
2 changed files with 14 additions and 2 deletions

View File

@@ -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)