From 47345a207e4b40d96878071164b4ab29a224ac92 Mon Sep 17 00:00:00 2001 From: "Chris (Someguy123)" Date: Tue, 17 Mar 2020 22:32:21 +0000 Subject: [PATCH] 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. --- tests/test_net.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_net.py b/tests/test_net.py index b3c9df2..efbb7ae 100644 --- a/tests/test_net.py +++ b/tests/test_net.py @@ -55,21 +55,22 @@ def test_ping_v6(self): except helpers.NetworkUnreachable as e: return pytest.skip(f"Skipping test TestGeneral.test_ping_v6 as network is unavailable: \"{str(e)}\"") - def _check_asn(self, asn, expected_name): + def _check_asn(self, asn, *expected_names): if not HAS_DNSPYTHON: return pytest.skip(f"Skipping asn_to_name tests as dnspython is not installed...") name = helpers.asn_to_name(asn) - self.assertEqual(name, expected_name, msg=f"asn_to_name({asn}) '{name}' == '{expected_name}'") + expected_names = list(expected_names) + self.assertIn(name, expected_names, msg=f"asn_to_name({asn}) '{name}' in: {expected_names}") @pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_int requires package 'dnspython'") def test_asn_to_name_int(self): """Test Privex's ASN (as an int) 210083 resolves to 'PRIVEX, SE'""" - self._check_asn(210083, 'PRIVEX, SE') + self._check_asn(210083, 'PRIVEX, SE', 'PRIVEX INC, SE', 'Privex Inc, SE') @pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_str requires package 'dnspython'") def test_asn_to_name_str(self): """Test Cloudflare's ASN (as a str) '13335' resolves to 'CLOUDFLARENET - Cloudflare, Inc., US'""" - self._check_asn('13335', 'CLOUDFLARENET - Cloudflare, Inc., US') + self._check_asn('13335', 'CLOUDFLARENET - Cloudflare, Inc., US', 'CLOUDFLARENET, US') @pytest.mark.skipif(not HAS_DNSPYTHON, reason="test_asn_to_name_erroneous requires package 'dnspython'") def test_asn_to_name_erroneous(self):