Bring back the file that I accidentally rm -f

pull/20771/head
Lidi Zheng 5 years ago
parent 57a0173e5c
commit 1ebaace7f1
  1. 29
      src/python/grpcio_tests/tests_aio/unit/_test_base.py
  2. 5
      src/python/grpcio_tests/tests_aio/unit/init_test.py
  3. 6
      src/python/grpcio_tests/tests_aio/unit/server_test.py

@ -0,0 +1,29 @@
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
import unittest
from grpc.experimental import aio
class AioTestBase(unittest.TestCase):
def setUp(self):
self._loop = asyncio.new_event_loop()
asyncio.set_event_loop(self._loop)
aio.init_grpc_aio()
@property
def loop(self):
return self._loop

@ -19,6 +19,7 @@ import unittest
import grpc
from grpc.experimental import aio
from tests_aio.unit._test_server import start_test_server
from tests_aio.unit._test_base import AioTestBase
class TestAioRpcError(unittest.TestCase):
@ -60,7 +61,7 @@ class TestAioRpcError(unittest.TestCase):
second_aio_rpc_error.__class__)
class TestInsecureChannel(unittest.TestCase):
class TestInsecureChannel(AioTestBase):
def test_insecure_channel(self):
@ -70,7 +71,7 @@ class TestInsecureChannel(unittest.TestCase):
channel = aio.insecure_channel(server_target)
self.assertIsInstance(channel, aio.Channel)
asyncio.get_event_loop().run_until_complete(coro())
self.loop.run_until_complete(coro())
if __name__ == '__main__':

@ -20,6 +20,7 @@ import grpc
from grpc.experimental import aio
from src.proto.grpc.testing import messages_pb2
from src.proto.grpc.testing import benchmark_service_pb2_grpc
from tests_aio.unit._test_base import AioTestBase
_TEST_METHOD_PATH = ''
@ -37,10 +38,9 @@ class GenericHandler(grpc.GenericRpcHandler):
return grpc.unary_unary_rpc_method_handler(unary_unary)
class TestServer(unittest.TestCase):
class TestServer(AioTestBase):
def test_unary_unary(self):
loop = asyncio.get_event_loop()
async def test_unary_unary_body():
server = aio.server()
@ -53,7 +53,7 @@ class TestServer(unittest.TestCase):
response = await unary_call(_REQUEST)
self.assertEqual(response, _RESPONSE)
loop.run_until_complete(test_unary_unary_body())
self.loop.run_until_complete(test_unary_unary_body())
if __name__ == '__main__':

Loading…
Cancel
Save