@@ -603,7 +603,7 @@ def __str__(self) -> str:
603603MateGiven = MateGivenType ()
604604
605605
606- class MockTransport (asyncio .SubprocessTransport ):
606+ class MockTransport (asyncio .SubprocessTransport , asyncio . WriteTransport ):
607607 def __init__ (self , protocol : "EngineProtocol" ) -> None :
608608 super ().__init__ ()
609609 self .protocol = protocol
@@ -621,7 +621,7 @@ def expect_ping(self) -> None:
621621 def assert_done (self ) -> None :
622622 assert not self .expectations , f"pending expectations: { self .expectations } "
623623
624- def get_pipe_transport (self , fd : int ) -> "MockTransport" : # type: ignore
624+ def get_pipe_transport (self , fd : int ) -> Optional [ asyncio . BaseTransport ]:
625625 assert fd == 0 , f"expected 0 for stdin, got { fd } "
626626 return self
627627
@@ -697,9 +697,9 @@ def send_line(self, line: str) -> None:
697697 LOGGER .debug ("%s: << %s" , self , line )
698698 assert self .transport is not None , "cannot send line before connection is made"
699699 stdin = self .transport .get_pipe_transport (0 )
700- assert stdin is not None , "no pipe for stdin"
701- stdin .write (line .encode ("utf-8" ))
702- stdin .write (b"\n " )
700+ # WriteTransport expected, but not checked to allow duck typing.
701+ stdin .write (line .encode ("utf-8" )) # type: ignore
702+ stdin .write (b"\n " ) # type: ignore
703703
704704 def pipe_data_received (self , fd : int , data : Union [bytes , str ]) -> None :
705705 self .buffer [fd ].extend (data ) # type: ignore
0 commit comments