diff --git a/src/python/grpcio_tests/tests_aio/unit/call_test.py b/src/python/grpcio_tests/tests_aio/unit/call_test.py index 2dc5e806115..3ce2a2f7b52 100644 --- a/src/python/grpcio_tests/tests_aio/unit/call_test.py +++ b/src/python/grpcio_tests/tests_aio/unit/call_test.py @@ -218,20 +218,21 @@ class TestUnaryUnaryCall(_MulticallableTestMixin, AioTestBase): class TestUnaryStreamCall(_MulticallableTestMixin, AioTestBase): async def test_call_rpc_error(self): - async with aio.insecure_channel(UNREACHABLE_TARGET) as channel: - request = messages_pb2.StreamingOutputCallRequest() - stub = test_pb2_grpc.TestServiceStub(channel) - call = stub.StreamingOutputCall(request) + channel = aio.insecure_channel(UNREACHABLE_TARGET) + request = messages_pb2.StreamingOutputCallRequest() + stub = test_pb2_grpc.TestServiceStub(channel) + call = stub.StreamingOutputCall(request) - with self.assertRaises(aio.AioRpcError) as exception_context: - async for response in call: - pass + with self.assertRaises(aio.AioRpcError) as exception_context: + async for response in call: + pass - self.assertEqual(grpc.StatusCode.UNAVAILABLE, - exception_context.exception.code()) + self.assertEqual(grpc.StatusCode.UNAVAILABLE, + exception_context.exception.code()) - self.assertTrue(call.done()) - self.assertEqual(grpc.StatusCode.UNAVAILABLE, await call.code()) + self.assertTrue(call.done()) + self.assertEqual(grpc.StatusCode.UNAVAILABLE, await call.code()) + await channel.close() async def test_cancel_unary_stream(self): # Prepares the request