File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,23 +58,6 @@ def setUp(self):
5858 if is_monkey_patched ():
5959 raise unittest .SkipTest ("Can't test asyncore with monkey patching" )
6060
61- def test_partial_send (self ):
62- c = self .make_connection ()
63-
64- # only write the first four bytes of the OptionsMessage
65- write_size = 4
66- c .socket .send .side_effect = None
67- c .socket .send .return_value = write_size
68- c .handle_write ()
69-
70- msg_size = 9 # v3+ frame header
71- expected_writes = int (math .ceil (float (msg_size ) / write_size ))
72- size_mod = msg_size % write_size
73- last_write_size = size_mod if size_mod else write_size
74- self .assertFalse (c .is_defunct )
75- self .assertEqual (expected_writes , c .socket .send .call_count )
76- self .assertEqual (last_write_size , len (c .socket .send .call_args [0 ][0 ]))
77-
7861 def test_socket_error_on_read (self ):
7962 c = self .make_connection ()
8063
Original file line number Diff line number Diff line change @@ -62,23 +62,6 @@ def setUp(self):
6262 for p in patchers :
6363 p .start ()
6464
65- def test_partial_send (self ):
66- c = self .make_connection ()
67-
68- # only write the first four bytes of the OptionsMessage
69- write_size = 4
70- c ._socket .send .side_effect = None
71- c ._socket .send .return_value = write_size
72- c .handle_write (None , 0 )
73-
74- msg_size = 9 # v3+ frame header
75- expected_writes = int (math .ceil (float (msg_size ) / write_size ))
76- size_mod = msg_size % write_size
77- last_write_size = size_mod if size_mod else write_size
78- self .assertFalse (c .is_defunct )
79- self .assertEqual (expected_writes , c ._socket .send .call_count )
80- self .assertEqual (last_write_size , len (c ._socket .send .call_args [0 ][0 ]))
81-
8265 def test_socket_error_on_read (self ):
8366 c = self .make_connection ()
8467
Original file line number Diff line number Diff line change 2323from mock import Mock
2424
2525import errno
26+ import math
2627import os
2728from socket import error as socket_error
2829
@@ -321,3 +322,21 @@ def test_blocking_on_write(self):
321322 c .handle_write (* self .null_handle_function_args )
322323 self .assertFalse (c .is_defunct )
323324 self .assertTrue (self .get_socket (c ).send .call_args is not None )
325+
326+ def test_partial_send (self ):
327+ c = self .make_connection ()
328+
329+ # only write the first four bytes of the OptionsMessage
330+ write_size = 4
331+ self .get_socket (c ).send .side_effect = None
332+ self .get_socket (c ).send .return_value = write_size
333+ c .handle_write (* self .null_handle_function_args )
334+
335+ msg_size = 9 # v3+ frame header
336+ expected_writes = int (math .ceil (float (msg_size ) / write_size ))
337+ size_mod = msg_size % write_size
338+ last_write_size = size_mod if size_mod else write_size
339+ self .assertFalse (c .is_defunct )
340+ self .assertEqual (expected_writes , self .get_socket (c ).send .call_count )
341+ self .assertEqual (last_write_size ,
342+ len (self .get_socket (c ).send .call_args [0 ][0 ]))
You can’t perform that action at this time.
0 commit comments