@@ -115,13 +115,13 @@ def test_second_send_fails():
115115def test_first_read_fails ():
116116 mocket .getaddrinfo .return_value = ((None , None , None , None , (ip , 80 )),)
117117 sock = mocket .Mocket (b"" )
118+ sock2 = mocket .Mocket (headers + encoded )
118119 mocket .socket .call_count = 0 # Reset call count
119- mocket .socket .side_effect = [sock ]
120+ mocket .socket .side_effect = [sock , sock2 ]
120121
121122 adafruit_requests .set_socket (mocket , mocket .interface )
122123
123- with pytest .raises (RuntimeError ):
124- r = adafruit_requests .get ("http://" + host + "/testwifi/index.html" )
124+ r = adafruit_requests .get ("http://" + host + "/testwifi/index.html" )
125125
126126 sock .send .assert_has_calls (
127127 [mock .call (b"testwifi/index.html" ),]
@@ -131,10 +131,16 @@ def test_first_read_fails():
131131 [mock .call (b"Host: " ), mock .call (host .encode ("utf-8" )), mock .call (b"\r \n " ),]
132132 )
133133
134+
135+ sock2 .send .assert_has_calls (
136+ [mock .call (b"Host: " ), mock .call (host .encode ("utf-8" )), mock .call (b"\r \n " ),]
137+ )
138+
134139 sock .connect .assert_called_once_with ((ip , 80 ))
140+ sock2 .connect .assert_called_once_with ((ip , 80 ))
135141 # Make sure that the socket is closed after the first receive fails.
136142 sock .close .assert_called_once ()
137- assert mocket .socket .call_count == 1
143+ assert mocket .socket .call_count == 2
138144
139145
140146def test_second_tls_connect_fails ():
0 commit comments