Skip to content

Commit

Permalink
grpc: remove handling for pre python 3.8 import errors
Browse files Browse the repository at this point in the history
While at it remove pytes asyncio markers that are not needed when
running tests in IsolatedAsyncioTestCase
  • Loading branch information
xrmx committed May 23, 2024
1 parent c28f9b8 commit fc04f5d
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ protobuf==3.20.3
py==1.11.0
py-cpuinfo==9.0.0
pytest==7.1.3
pytest-asyncio==0.23.5
pytest-benchmark==4.0.0
tomli==2.0.1
typing_extensions==4.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,9 @@
# 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.
try:
from unittest import IsolatedAsyncioTestCase
except ImportError:
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
# simplifies the following tests. Without it, the amount of test code
# increases significantly, with most of the additional code handling
# the asyncio set up.
from unittest import TestCase

class IsolatedAsyncioTestCase(TestCase):
def run(self, result=None):
self.skipTest(
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
)

from unittest import IsolatedAsyncioTestCase

import grpc
import pytest

import opentelemetry.instrumentation.grpc
from opentelemetry import trace
Expand Down Expand Up @@ -65,7 +50,6 @@ async def intercept_unary_unary(
return await continuation(client_call_details, request)


@pytest.mark.asyncio
class TestAioClientInterceptor(TestBase, IsolatedAsyncioTestCase):
def setUp(self):
super().setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,10 @@
# 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.
try:
from unittest import IsolatedAsyncioTestCase
except ImportError:
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
# simplifies the following tests. Without it, the amount of test code
# increases significantly, with most of the additional code handling
# the asyncio set up.
from unittest import TestCase

class IsolatedAsyncioTestCase(TestCase):
def run(self, result=None):
self.skipTest(
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
)


import os
from unittest import mock
from unittest import IsolatedAsyncioTestCase, mock

import grpc
import pytest

from opentelemetry.instrumentation.grpc import (
GrpcAioInstrumentorClient,
Expand All @@ -50,7 +33,6 @@ def run(self, result=None):
from .protobuf import test_server_pb2_grpc # pylint: disable=no-name-in-module


@pytest.mark.asyncio
class TestAioClientInterceptorFiltered(TestBase, IsolatedAsyncioTestCase):
def setUp(self):
super().setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,9 @@
# 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.
try:
from unittest import IsolatedAsyncioTestCase
except ImportError:
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
# simplifies the following tests. Without it, the amount of test code
# increases significantly, with most of the additional code handling
# the asyncio set up.
from unittest import TestCase

class IsolatedAsyncioTestCase(TestCase):
def run(self, result=None):
self.skipTest(
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
)

from unittest import IsolatedAsyncioTestCase

import grpc
import pytest

from opentelemetry.instrumentation.grpc import GrpcAioInstrumentorClient
from opentelemetry.test.test_base import TestBase
Expand All @@ -54,7 +39,6 @@ def response_hook_with_exception(_span, _response):
raise Exception()


@pytest.mark.asyncio
class TestAioClientInterceptorWithHooks(TestBase, IsolatedAsyncioTestCase):
def setUp(self):
super().setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio

try:
from unittest import IsolatedAsyncioTestCase
except ImportError:
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
# simplifies the following tests. Without it, the amount of test code
# increases significantly, with most of the additional code handling
# the asyncio set up.
from unittest import TestCase

class IsolatedAsyncioTestCase(TestCase):
def run(self, result=None):
self.skipTest(
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
)

from unittest import IsolatedAsyncioTestCase

import grpc
import grpc.aio
import pytest

import opentelemetry.instrumentation.grpc
from opentelemetry import trace
Expand Down Expand Up @@ -97,7 +81,6 @@ async def run_with_test_server(
return resp


@pytest.mark.asyncio
class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
async def test_instrumentor(self):
"""Check that automatic instrumentation configures the interceptor"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,10 @@
# 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.
try:
from unittest import IsolatedAsyncioTestCase
except ImportError:
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
# simplifies the following tests. Without it, the amount of test code
# increases significantly, with most of the additional code handling
# the asyncio set up.
from unittest import TestCase

class IsolatedAsyncioTestCase(TestCase):
def run(self, result=None):
self.skipTest(
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
)

from unittest import IsolatedAsyncioTestCase

import grpc
import grpc.aio
import pytest

from opentelemetry import trace
from opentelemetry.instrumentation.grpc import (
Expand Down Expand Up @@ -68,7 +53,6 @@ async def run_with_test_server(
return resp


@pytest.mark.asyncio
class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
async def test_instrumentor(self):
"""Check that automatic instrumentation configures the interceptor"""
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ deps =
test: pytest-benchmark
coverage: pytest
coverage: pytest-cov
grpc: pytest-asyncio

; FIXME: add coverage testing
; FIXME: add mypy testing
Expand Down

0 comments on commit fc04f5d

Please sign in to comment.