(self)
| 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>") |
nothing calls this directly
no test coverage detected