Hitting the technical debt the hard way

pull/21232/head
Lidi Zheng 5 years ago
parent dc2ee66432
commit 32d05488f6
  1. 2
      src/python/grpcio_tests/commands.py
  2. 2
      src/python/grpcio_tests/tests/_runner.py
  3. 10
      src/python/grpcio_tests/tests_aio/unit/_test_base.py

@ -120,6 +120,8 @@ class TestAio(setuptools.Command):
def run(self): def run(self):
self._add_eggs_to_path() self._add_eggs_to_path()
from grpc.experimental.aio import init_grpc_aio
init_grpc_aio()
import tests import tests
loader = tests.Loader() loader = tests.Loader()

@ -115,6 +115,8 @@ class AugmentedCase(collections.namedtuple('AugmentedCase', ['case', 'id'])):
return super(cls, AugmentedCase).__new__(cls, case, id) return super(cls, AugmentedCase).__new__(cls, case, id)
# NOTE(lidiz) This complex wrapper is not triggering setUpClass nor
# tearDownClass. Do not use those methods, or fix this wrapper!
class Runner(object): class Runner(object):
def __init__(self, dedicated_threads=False): def __init__(self, dedicated_threads=False):

@ -46,14 +46,9 @@ def _get_default_loop(debug=True):
class AioTestBase(unittest.TestCase): class AioTestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls._loop = _get_default_loop()
aio.init_grpc_aio()
@property @property
def loop(self): def loop(self):
return self._loop return _get_default_loop()
def __getattribute__(self, name): def __getattribute__(self, name):
"""Overrides the loading logic to support coroutine functions.""" """Overrides the loading logic to support coroutine functions."""
@ -65,3 +60,6 @@ class AioTestBase(unittest.TestCase):
return _async_to_sync_decorator(attr, _get_default_loop()) return _async_to_sync_decorator(attr, _get_default_loop())
# For other attributes, let them pass. # For other attributes, let them pass.
return attr return attr
aio.init_grpc_aio()

Loading…
Cancel
Save