From fb54a30483429089e4c763475687ade6490bb7cb Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Wed, 3 Jun 2020 15:19:37 -0700 Subject: [PATCH] Ban gevent tests --- src/python/grpcio_tests/commands.py | 3 +++ .../tests/unit/_contextvars_propagation_test.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py index f7cd7c6b8a1..f6b5859ced4 100644 --- a/src/python/grpcio_tests/commands.py +++ b/src/python/grpcio_tests/commands.py @@ -220,6 +220,9 @@ class TestGevent(setuptools.Command): 'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity', # TODO(https://github.com/grpc/grpc/issues/15411) enable this test 'unit._local_credentials_test.LocalCredentialsTest', + # TODO(https://github.com/grpc/grpc/issues/22020) LocalCredentials + # aren't supported with custom io managers. + 'unit._contextvars_propagation_test', 'testing._time_test.StrictRealTimeTest', ) BANNED_WINDOWS_TESTS = ( diff --git a/src/python/grpcio_tests/tests/unit/_contextvars_propagation_test.py b/src/python/grpcio_tests/tests/unit/_contextvars_propagation_test.py index 9ff5473f165..1fee901c8f3 100644 --- a/src/python/grpcio_tests/tests/unit/_contextvars_propagation_test.py +++ b/src/python/grpcio_tests/tests/unit/_contextvars_propagation_test.py @@ -51,7 +51,7 @@ class _GenericHandler(grpc.GenericRpcHandler): def _server(): try: server = test_common.test_server() - target = '[::]:0' + target = 'localhost:0' port = server.add_insecure_port(target) server.add_generic_rpc_handlers((_GenericHandler(),)) server.start() @@ -65,21 +65,28 @@ if contextvars_supported(): _EXPECTED_VALUE = 24601 test_var = contextvars.ContextVar("test_var", default=None) - test_var.set(_EXPECTED_VALUE) + + def set_up_expected_context(): + test_var.set(_EXPECTED_VALUE) class TestCallCredentials(grpc.AuthMetadataPlugin): def __init__(self): self._recorded_value = None + self._invoked = False def __call__(self, context, callback): self._recorded_value = test_var.get() + self._invoked = True callback((), None) def assert_called(self, test): + test.assertTrue(self._invoked) test.assertEqual(_EXPECTED_VALUE, self._recorded_value) else: + def set_up_expected_context(): + pass class TestCallCredentials(grpc.AuthMetadataPlugin): @@ -93,6 +100,7 @@ else: class ContextVarsPropagationTest(unittest.TestCase): def test_propagation_to_auth_plugin(self): + set_up_expected_context() with _server() as port: target = "localhost:{}".format(port) local_credentials = grpc.local_channel_credentials()