Skip to content

Commit 47345a2

Browse files
committed
2.9.0 - Re-tagged with fixed tests
Github version has been re-tagged. No changes to actual package code, as tests are generally excluded. - `tests.test_net.TestNet._check_asn` now allows comparing against multiple AS names, reducing risk of ASN test breakage due to AS names changing. - Added additional AS names to `test_asn_to_name_int` and `test_asn_to_name_str` to repair test breakage caused by Cloudflare's AS name changing, and preventing breakage caused by AS name changes in future.
1 parent 48ce4b6 commit 47345a2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_net.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,22 @@ def test_ping_v6(self):
5555
except helpers.NetworkUnreachable as e:
5656
return pytest.skip(f"Skipping test TestGeneral.test_ping_v6 as network is unavailable: \"{str(e)}\"")
5757

58-
def _check_asn(self, asn, expected_name):
58+
def _check_asn(self, asn, *expected_names):
5959
if not HAS_DNSPYTHON:
6060
return pytest.skip(f"Skipping asn_to_name tests as dnspython is not installed...")
6161
name = helpers.asn_to_name(asn)
62-
self.assertEqual(name, expected_name, msg=f"asn_to_name({asn}) '{name}' == '{expected_name}'")
62+
expected_names = list(expected_names)
63+
self.assertIn(name, expected_names, msg=f"asn_to_name({asn}) '{name}' in: {expected_names}")
6364

6465
@pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_int requires package 'dnspython'")
6566
def test_asn_to_name_int(self):
6667
"""Test Privex's ASN (as an int) 210083 resolves to 'PRIVEX, SE'"""
67-
self._check_asn(210083, 'PRIVEX, SE')
68+
self._check_asn(210083, 'PRIVEX, SE', 'PRIVEX INC, SE', 'Privex Inc, SE')
6869

6970
@pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_str requires package 'dnspython'")
7071
def test_asn_to_name_str(self):
7172
"""Test Cloudflare's ASN (as a str) '13335' resolves to 'CLOUDFLARENET - Cloudflare, Inc., US'"""
72-
self._check_asn('13335', 'CLOUDFLARENET - Cloudflare, Inc., US')
73+
self._check_asn('13335', 'CLOUDFLARENET - Cloudflare, Inc., US', 'CLOUDFLARENET, US')
7374

7475
@pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_erroneous requires package 'dnspython'")
7576
def test_asn_to_name_erroneous(self):

0 commit comments

Comments
 (0)