From d736f6f080c27a0eddc71b97d2d9b26f81b30e29 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 9 Apr 2024 19:03:41 +0000 Subject: [PATCH] remove usage of pytest --- .../grpcio_tests/tests/unit/_api_test.py | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/python/grpcio_tests/tests/unit/_api_test.py b/src/python/grpcio_tests/tests/unit/_api_test.py index d72c2868595..e9e904ff4a0 100644 --- a/src/python/grpcio_tests/tests/unit/_api_test.py +++ b/src/python/grpcio_tests/tests/unit/_api_test.py @@ -18,7 +18,6 @@ import threading import unittest import grpc -import pytest from tests.unit import _from_grpc_import_star from tests.unit import test_common @@ -112,23 +111,18 @@ class ChannelConnectivityTest(unittest.TestCase): ) -@pytest.fixture(scope="class") -def compute_engine_channel_credentials(request): - class TestCallCredentials(grpc.AuthMetadataPlugin): - def __call__(self, context, callback): - callback((), None) - - test_call_credentials = TestCallCredentials() - call_credentials = grpc.metadata_call_credentials( - test_call_credentials, "test call credentials" - ) - request.cls.compute_engine_channel_credentials = ( - grpc.compute_engine_channel_credentials(call_credentials) - ) - - -@pytest.mark.usefixtures("compute_engine_channel_credentials") class ChannelTest(unittest.TestCase): + def compute_engine_channel_credentials(self): + class TestCallCredentials(grpc.AuthMetadataPlugin): + def __call__(self, context, callback): + callback((), None) + + test_call_credentials = TestCallCredentials() + call_credentials = grpc.metadata_call_credentials( + test_call_credentials, "test call credentials" + ) + return grpc.compute_engine_channel_credentials(call_credentials) + def test_ssl_secure_channel(self): channel = grpc.secure_channel( "google.com:443", grpc.ssl_channel_credentials() @@ -137,7 +131,7 @@ class ChannelTest(unittest.TestCase): def test_compute_engine_secure_channel(self): channel = grpc.secure_channel( - "google.com:443", self.compute_engine_channel_credentials + "google.com:443", self.compute_engine_channel_credentials() ) channel.close() @@ -171,7 +165,7 @@ class ChannelTest(unittest.TestCase): wait_group.done() wait_group.wait() channel = grpc.secure_channel( - "google.com:443", self.compute_engine_channel_credentials + "google.com:443", self.compute_engine_channel_credentials() ) channel.close()