MCPcopy
hub / github.com/django/django / test_bad_query

Method test_bad_query

tests/gis_tests/test_geoip2.py:103–122  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

101 GeoIP2(invalid_path)
102
103 def test_bad_query(self):
104 g = GeoIP2(city="<invalid>")
105
106 functions = (g.city, g.geos, g.lat_lon, g.lon_lat)
107 msg = "Invalid GeoIP city data file: "
108 for function in functions:
109 with self.subTest(function=function.__qualname__):
110 with self.assertRaisesMessage(GeoIP2Exception, msg):
111 function("example.com")
112
113 functions += (g.country, g.country_code, g.country_name)
114 values = (123, 123.45, b"", (), [], {}, set(), frozenset(), GeoIP2)
115 msg = (
116 "GeoIP query must be a string or instance of IPv4Address or IPv6Address, "
117 "not type"
118 )
119 for function, value in itertools.product(functions, values):
120 with self.subTest(function=function.__qualname__, type=type(value)):
121 with self.assertRaisesMessage(TypeError, msg):
122 function(value)
123
124 def test_country(self):
125 g = GeoIP2(city="<invalid>")

Callers

nothing calls this directly

Calls 3

GeoIP2Class · 0.90
functionFunction · 0.85
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected