@@ -128,7 +128,7 @@ def test_geoip_v4_privex1(self):
128
128
self .assertEqual (data .country , 'Sweden' )
129
129
self .assertEqual (data .country_code , 'SE' )
130
130
self .assertEqual (data .city , 'Stockholm' )
131
- self .assertEqual (str (data .network ), '185.130.44.0/24' )
131
+ self .assertIn (str (data .network ), [ '185.130.44.0/24' , '185.130.44.0/23' , '185.130.44.0/22' ] )
132
132
133
133
def test_geoip_v6_privex1 (self ):
134
134
"""Test ``2a07:e00::333`` resolves correctly using :meth:`.geoip.geolocate_ip`"""
@@ -138,7 +138,8 @@ def test_geoip_v6_privex1(self):
138
138
self .assertEqual (data .country , 'Sweden' )
139
139
self .assertEqual (data .country_code , 'SE' )
140
140
self .assertEqual (data .city , 'Stockholm' )
141
- self .assertEqual (str (data .network ), '2a07:e00::/48' )
141
+ # GeoIP's network value isn't reliable, so we simple check it starts with 2a07:e00::/
142
+ self .assertIn ('2a07:e00::/' , str (data .network ))
142
143
143
144
def test_geoip_v4_hetzner1 (self ):
144
145
"""Test ``95.216.3.171`` resolves correctly using :meth:`.geoip.geolocate_ip`"""
@@ -148,7 +149,9 @@ def test_geoip_v4_hetzner1(self):
148
149
self .assertEqual (data .country , 'Finland' )
149
150
self .assertEqual (data .country_code , 'FI' )
150
151
self .assertIn (data .city , [None , 'Helsinki' ])
151
- self .assertEqual (str (data .network ), '95.216.0.0/15' )
152
+ # GeoIP's network value isn't reliable, so we simply check the first 5 characters, and confirm there's a / present
153
+ self .assertTrue (str (data .network ).startswith ('95.21' ))
154
+ self .assertIn ('/' , str (data .network ))
152
155
153
156
def test_geoip_v6_hetzner1 (self ):
154
157
"""Test ``2a01:4f9:2a:3d4::2`` resolves correctly using :meth:`.geoip.geolocate_ip`"""
@@ -163,6 +166,7 @@ def test_geoip_v6_hetzner1(self):
163
166
self .assertIn (data .country_code , ['FI' , 'DE' ])
164
167
# Again, the IPv6 network that this address belongs to can fluctuate - so we just make sure it starts with 2a01:4f
165
168
self .assertTrue (str (data .network ).startswith ('2a01:4f' ))
169
+ self .assertIn ('/' , str (data .network ))
166
170
167
171
def test_geoip_v4_local (self ):
168
172
with self .assertRaises (GeoIPAddressNotFound ):
0 commit comments