Skip to content

Commit

Permalink
Fix running async psycopg tests (#2540)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx authored Jun 5, 2024
1 parent c06fd1d commit 95fea2b
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 194 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() # pylint: disable=broad-exception-raised


@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
Loading

0 comments on commit 95fea2b

Please sign in to comment.