File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -111,11 +111,10 @@ def create_fake_ssl_context(
111
111
112
112
113
113
def _get_radio_hash_key (radio ):
114
- class_name = radio .__class__ .__name__
115
- # trying to use wifi.radio as a key results in:
116
- # TypeError: unsupported type for __hash__: 'Radio'
117
- # So just use the class name in this case
118
- return class_name if class_name == "Radio" else radio
114
+ try :
115
+ return hash (radio )
116
+ except TypeError :
117
+ return radio .__class__ .__name__
119
118
120
119
121
120
def get_radio_socketpool (radio ):
Original file line number Diff line number Diff line change 13
13
import adafruit_connection_manager
14
14
15
15
16
+ def test__get_radio_hash_key ():
17
+ radio = mocket .MockRadio .Radio ()
18
+ assert adafruit_connection_manager ._get_radio_hash_key (radio ) == hash (radio )
19
+
20
+
21
+ def test__get_radio_hash_key_not_hashable ():
22
+ radio = mocket .MockRadio .Radio ()
23
+
24
+ with mock .patch ("builtins.hash" , side_effect = TypeError ()):
25
+ assert adafruit_connection_manager ._get_radio_hash_key (radio ) == "Radio"
26
+
27
+
16
28
def test_get_radio_socketpool_wifi ( # pylint: disable=unused-argument
17
29
circuitpython_socketpool_module ,
18
30
):
You can’t perform that action at this time.
0 commit comments