Skip to content
Myr

Changed tests to use socket.sendall instead of socket.send

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Braulio Valdivielso Martínez · committed by Braulio Valdivielso Martínez · parent 44161ac · Browse files · 1 file+8 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−8 removed

  • tests:+8 added−8 removed

1 file+8 added−8 removed

modified:tests/test_testserver.py+8 added-8 removed
11 unmodified lines
12 answer = b"yeah, success"13 def handler(sock):14 text = sock.recv(1000)15 assert text == question 16 sock.send(answer)16 sock.sendall(answer)17 18 with Server(handler) as (host, port):19 sock = socket.socket()20 sock.connect((host, port))21 sock.send(question)21 sock.sendall(question)22 text = sock.recv(1000)23 assert text == answer24 sock.close()25
34 unmodified lines
6061 with Server.basic_response_server(wait_to_close_event=block_server) as (host, port):62 sock = socket.socket()63 sock.connect((host, port))64 sock.send(b'send something')64 sock.sendall(b'send something')65 time.sleep(2.5)66 sock.send(b'still alive')66 sock.sendall(b'still alive')67 block_server.set() # release server block6869 def test_multiple_requests(self):70 requests_to_handle = 5
19 unmodified lines
90 sock1 = socket.socket()91 sock2 = socket.socket()92 93 sock1.connect(address)94 sock1.send(first_request.encode())94 sock1.sendall(first_request.encode())95 sock1.close()9697 sock2.connect(address)98 sock2.send(second_request.encode())98 sock2.sendall(second_request.encode())99 sock2.close()100101 assert server.handler_results[0] == first_request102 assert server.handler_results[1] == second_request
4 unmodified lines
107 with server as address:108 sock = socket.socket()109 sock.connect(address)110 time.sleep(1.5)111 sock.send(b"hehehe, not received")111 sock.sendall(b"hehehe, not received")112 sock.close()113114 assert server.handler_results[0] == ""115
5 unmodified lines
121 with server as address:122 sock = socket.socket() 123 sock.connect(address)124 time.sleep(1.5)125 sock.send(data.encode())125 sock.sendall(data.encode())126 sock.close()127 128 assert server.handler_results[0] == data