diff --git a/adafruit_connection_manager.py b/adafruit_connection_manager.py index 27f8a7b..b195d19 100644 --- a/adafruit_connection_manager.py +++ b/adafruit_connection_manager.py @@ -74,7 +74,7 @@ def wrap_socket( # pylint: disable=unused-argument if hasattr(self._iface, "TLS_MODE"): return _FakeSSLSocket(socket, self._iface.TLS_MODE) - raise AttributeError("This radio does not support TLS/HTTPS") + raise ValueError("This radio does not support TLS/HTTPS") def create_fake_ssl_context( @@ -159,7 +159,7 @@ def get_radio_socketpool(radio): ssl_context = create_fake_ssl_context(pool, radio) else: - raise AttributeError(f"Unsupported radio class: {class_name}") + raise ValueError(f"Unsupported radio class: {class_name}") _global_key_by_socketpool[pool] = key _global_socketpools[key] = pool diff --git a/tests/get_radio_test.py b/tests/get_radio_test.py index 9844e9e..5631bdb 100644 --- a/tests/get_radio_test.py +++ b/tests/get_radio_test.py @@ -55,7 +55,7 @@ def test_get_radio_socketpool_wiznet5k( # pylint: disable=unused-argument def test_get_radio_socketpool_unsupported(): radio = mocket.MockRadio.Unsupported() - with pytest.raises(AttributeError) as context: + with pytest.raises(ValueError) as context: adafruit_connection_manager.get_radio_socketpool(radio) assert "Unsupported radio class" in str(context) @@ -100,7 +100,7 @@ def test_get_radio_ssl_context_wiznet5k( # pylint: disable=unused-argument def test_get_radio_ssl_context_unsupported(): radio = mocket.MockRadio.Unsupported() - with pytest.raises(AttributeError) as context: + with pytest.raises(ValueError) as context: adafruit_connection_manager.get_radio_ssl_context(radio) assert "Unsupported radio class" in str(context) diff --git a/tests/protocol_test.py b/tests/protocol_test.py index 98b5296..5ddac99 100644 --- a/tests/protocol_test.py +++ b/tests/protocol_test.py @@ -18,7 +18,7 @@ def test_get_https_no_ssl(): connection_manager = adafruit_connection_manager.ConnectionManager(mock_pool) # verify not sending in a SSL context for a HTTPS call errors - with pytest.raises(AttributeError) as context: + with pytest.raises(ValueError) as context: connection_manager.get_socket(mocket.MOCK_HOST_1, 443, "https:") assert "ssl_context must be set" in str(context) diff --git a/tests/ssl_context_test.py b/tests/ssl_context_test.py index 2f2e370..02bf96e 100644 --- a/tests/ssl_context_test.py +++ b/tests/ssl_context_test.py @@ -58,7 +58,7 @@ def test_connect_wiznet5k_https_not_supported( # pylint: disable=unused-argumen connection_manager = adafruit_connection_manager.ConnectionManager(mock_pool) # verify a HTTPS call for a board without built in WiFi and SSL support errors - with pytest.raises(AttributeError) as context: + with pytest.raises(ValueError) as context: connection_manager.get_socket( mocket.MOCK_HOST_1, 443, "https:", ssl_context=ssl_context )