async def inner_test() -> None: async with TestServer(ip="::1") as sa: assert sa.ip and sa.port async with get_client( StreamTestService, host=sa.ip, port=sa.port, client_type=ClientType.THRIFT_ROCKET_CLIENT_TYPE, ) as client: resp, stream = await client.returnresponseandstream( Included(from_=39, to=42)) self.assertEqual(resp, Included(from_=100, to=200)) expected_to = 39 async for n in stream: self.assertEqual(n, Included(from_=39, to=expected_to)) expected_to += 1 self.assertEqual(expected_to, 42)
async def returnresponseandstream( self, foo: Included, ) -> Tuple[Included, AsyncGenerator[Included, None]]: resp = Included(from_=100, to=200) async def inner() -> AsyncGenerator[Included, None]: for x in range(foo.from_, foo.to): yield Included(from_=foo.from_, to=x) return (resp, inner())
async def inner_test() -> None: async with TestServer(ip="::1") as sa: ip, port = sa.ip, sa.port assert ip and port async with get_client( StreamTestService, # pyre-fixme[6]: Expected `Union[ipaddress.IPv4Address, # ipaddress.IPv6Address, str]` for 2nd param but got `Union[None, # ipaddress.IPv4Address, ipaddress.IPv6Address]`. host=ip, port=port, client_type=ClientType.THRIFT_ROCKET_CLIENT_TYPE, ) as client: # pyre-fixme[23]: may be a pyre bug? resp, stream = await client.returnresponseandstream( Included(from_=39, to=42)) self.assertEqual(resp, Included(from_=100, to=200)) expected_to = 39 async for n in stream: self.assertEqual(n, Included(from_=39, to=expected_to)) expected_to += 1 self.assertEqual(expected_to, 42)
async def inner() -> AsyncGenerator[Included, None]: for x in range(foo.from_, foo.to): yield Included(from_=foo.from_, to=x)