@@ -936,13 +936,13 @@ def write(self, data: bytes) -> None:
936
936
937
937
if line .startswith ("ping " ) and self .expected_pings :
938
938
self .expected_pings -= 1
939
- self .protocol .pipe_data_received (1 , line .replace ("ping " , "pong " ).encode ("utf-8" ) + b" \n " )
939
+ self .protocol .pipe_data_received (1 , ( line .replace ("ping " , "pong " ) + " \n " ) .encode ("utf-8" ))
940
940
else :
941
941
assert self .expectations , f"unexpected: { line !r} "
942
942
expectation , responses = self .expectations .popleft ()
943
943
assert expectation == line , f"expected { expectation } , got: { line } "
944
944
if responses :
945
- self .protocol .pipe_data_received (1 , "\n " .join (responses ).encode ("utf-8" ) + b" \n " )
945
+ self .protocol .pipe_data_received (1 , "\n " .join (responses + [ "" ] ).encode ("utf-8" ))
946
946
947
947
def get_pid (self ) -> int :
948
948
return id (self )
@@ -1010,8 +1010,7 @@ def send_line(self, line: str) -> None:
1010
1010
assert self .transport is not None , "cannot send line before connection is made"
1011
1011
stdin = self .transport .get_pipe_transport (0 )
1012
1012
# WriteTransport expected, but not checked to allow duck typing.
1013
- stdin .write (line .encode ("utf-8" )) # type: ignore
1014
- stdin .write (b"\n " ) # type: ignore
1013
+ stdin .write ((line + "\n " ).encode ("utf-8" )) # type: ignore
1015
1014
1016
1015
def pipe_data_received (self , fd : int , data : Union [bytes , str ]) -> None :
1017
1016
self .buffer [fd ].extend (data ) # type: ignore
0 commit comments