Fix the grpc.aio import hack and its unit test

pull/24416/head
Lidi Zheng 4 years ago
parent d5b065ac17
commit 684b5d1f47
  1. 2
      src/python/grpcio/grpc/__init__.py
  2. 8
      src/python/grpcio_tests/tests_aio/unit/init_test.py

@ -2125,6 +2125,6 @@ except ImportError:
pass
# Prevents import order issue in the case of renamed path.
if sys.version_info >= (3, 6) and __name__ == "grpc.__init__":
if sys.version_info >= (3, 6) and __name__ == "grpc":
from grpc import aio # pylint: disable=ungrouped-imports
sys.modules.update({'grpc.aio': aio})

@ -14,17 +14,15 @@
import logging
import unittest
from tests_aio.unit._test_base import AioTestBase
class TestInit(unittest.TestCase):
class TestInit(AioTestBase):
async def test_grpc(self):
def test_grpc(self):
import grpc # pylint: disable=wrong-import-position
channel = grpc.aio.insecure_channel('dummy')
self.assertIsInstance(channel, grpc.aio.Channel)
async def test_grpc_dot_aio(self):
def test_grpc_dot_aio(self):
import grpc.aio # pylint: disable=wrong-import-position
channel = grpc.aio.insecure_channel('dummy')
self.assertIsInstance(channel, grpc.aio.Channel)

Loading…
Cancel
Save