@@ -128,7 +128,7 @@ def test_geoip_v4_privex1(self):
128128 self .assertEqual (data .country , 'Sweden' )
129129 self .assertEqual (data .country_code , 'SE' )
130130 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' ] )
132132
133133 def test_geoip_v6_privex1 (self ):
134134 """Test ``2a07:e00::333`` resolves correctly using :meth:`.geoip.geolocate_ip`"""
@@ -138,7 +138,8 @@ def test_geoip_v6_privex1(self):
138138 self .assertEqual (data .country , 'Sweden' )
139139 self .assertEqual (data .country_code , 'SE' )
140140 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 ))
142143
143144 def test_geoip_v4_hetzner1 (self ):
144145 """Test ``95.216.3.171`` resolves correctly using :meth:`.geoip.geolocate_ip`"""
@@ -148,7 +149,9 @@ def test_geoip_v4_hetzner1(self):
148149 self .assertEqual (data .country , 'Finland' )
149150 self .assertEqual (data .country_code , 'FI' )
150151 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 ))
152155
153156 def test_geoip_v6_hetzner1 (self ):
154157 """Test ``2a01:4f9:2a:3d4::2`` resolves correctly using :meth:`.geoip.geolocate_ip`"""
@@ -163,6 +166,7 @@ def test_geoip_v6_hetzner1(self):
163166 self .assertIn (data .country_code , ['FI' , 'DE' ])
164167 # Again, the IPv6 network that this address belongs to can fluctuate - so we just make sure it starts with 2a01:4f
165168 self .assertTrue (str (data .network ).startswith ('2a01:4f' ))
169+ self .assertIn ('/' , str (data .network ))
166170
167171 def test_geoip_v4_local (self ):
168172 with self .assertRaises (GeoIPAddressNotFound ):
0 commit comments