Skip to content

Commit 9174ce3

Browse files
committed
use ValueError instead of AttributeError for incorrect args
1 parent 99f8972 commit 9174ce3

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

adafruit_connection_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def wrap_socket( # pylint: disable=unused-argument
7474
if hasattr(self._iface, "TLS_MODE"):
7575
return _FakeSSLSocket(socket, self._iface.TLS_MODE)
7676

77-
raise AttributeError("This radio does not support TLS/HTTPS")
77+
raise ValueError("This radio does not support TLS/HTTPS")
7878

7979

8080
def create_fake_ssl_context(
@@ -159,7 +159,7 @@ def get_radio_socketpool(radio):
159159
ssl_context = create_fake_ssl_context(pool, radio)
160160

161161
else:
162-
raise AttributeError(f"Unsupported radio class: {class_name}")
162+
raise ValueError(f"Unsupported radio class: {class_name}")
163163

164164
_global_key_by_socketpool[pool] = key
165165
_global_socketpools[key] = pool

tests/get_radio_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_get_radio_socketpool_wiznet5k( # pylint: disable=unused-argument
5555

5656
def test_get_radio_socketpool_unsupported():
5757
radio = mocket.MockRadio.Unsupported()
58-
with pytest.raises(AttributeError) as context:
58+
with pytest.raises(ValueError) as context:
5959
adafruit_connection_manager.get_radio_socketpool(radio)
6060
assert "Unsupported radio class" in str(context)
6161

@@ -100,7 +100,7 @@ def test_get_radio_ssl_context_wiznet5k( # pylint: disable=unused-argument
100100

101101
def test_get_radio_ssl_context_unsupported():
102102
radio = mocket.MockRadio.Unsupported()
103-
with pytest.raises(AttributeError) as context:
103+
with pytest.raises(ValueError) as context:
104104
adafruit_connection_manager.get_radio_ssl_context(radio)
105105
assert "Unsupported radio class" in str(context)
106106

tests/protocol_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_get_https_no_ssl():
1818
connection_manager = adafruit_connection_manager.ConnectionManager(mock_pool)
1919

2020
# verify not sending in a SSL context for a HTTPS call errors
21-
with pytest.raises(AttributeError) as context:
21+
with pytest.raises(ValueError) as context:
2222
connection_manager.get_socket(mocket.MOCK_HOST_1, 443, "https:")
2323
assert "ssl_context must be set" in str(context)
2424

tests/ssl_context_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_connect_wiznet5k_https_not_supported( # pylint: disable=unused-argumen
5858
connection_manager = adafruit_connection_manager.ConnectionManager(mock_pool)
5959

6060
# verify a HTTPS call for a board without built in WiFi and SSL support errors
61-
with pytest.raises(AttributeError) as context:
61+
with pytest.raises(ValueError) as context:
6262
connection_manager.get_socket(
6363
mocket.MOCK_HOST_1, 443, "https:", ssl_context=ssl_context
6464
)

0 commit comments

Comments
 (0)