@@ -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,15 @@ def test_first_read_fails():
131131 [mock .call (b"Host: " ), mock .call (host .encode ("utf-8" )), mock .call (b"\r \n " ),]
132132 )
133133
134+ sock2 .send .assert_has_calls (
135+ [mock .call (b"Host: " ), mock .call (host .encode ("utf-8" )), mock .call (b"\r \n " ),]
136+ )
137+
134138 sock .connect .assert_called_once_with ((ip , 80 ))
139+ sock2 .connect .assert_called_once_with ((ip , 80 ))
135140 # Make sure that the socket is closed after the first receive fails.
136141 sock .close .assert_called_once ()
137- assert mocket .socket .call_count == 1
142+ assert mocket .socket .call_count == 2
138143
139144
140145def test_second_tls_connect_fails ():
0 commit comments