Skip to content

Commit 95fea2b

Browse files
authored
Fix running async psycopg tests (open-telemetry#2540)
1 parent c06fd1d commit 95fea2b

File tree

8 files changed

+120
-194
lines changed

8 files changed

+120
-194
lines changed

instrumentation/opentelemetry-instrumentation-grpc/test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ protobuf==3.20.3
1010
py==1.11.0
1111
py-cpuinfo==9.0.0
1212
pytest==7.1.3
13-
pytest-asyncio==0.23.5
1413
pytest-benchmark==4.0.0
1514
tomli==2.0.1
1615
typing_extensions==4.9.0

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_client_interceptor.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
try:
15-
from unittest import IsolatedAsyncioTestCase
16-
except ImportError:
17-
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
18-
# simplifies the following tests. Without it, the amount of test code
19-
# increases significantly, with most of the additional code handling
20-
# the asyncio set up.
21-
from unittest import TestCase
22-
23-
class IsolatedAsyncioTestCase(TestCase):
24-
def run(self, result=None):
25-
self.skipTest(
26-
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
27-
)
28-
14+
from unittest import IsolatedAsyncioTestCase
2915

3016
import grpc
31-
import pytest
3217

3318
import opentelemetry.instrumentation.grpc
3419
from opentelemetry import trace
@@ -65,7 +50,6 @@ async def intercept_unary_unary(
6550
return await continuation(client_call_details, request)
6651

6752

68-
@pytest.mark.asyncio
6953
class TestAioClientInterceptor(TestBase, IsolatedAsyncioTestCase):
7054
def setUp(self):
7155
super().setUp()

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_client_interceptor_filter.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
try:
15-
from unittest import IsolatedAsyncioTestCase
16-
except ImportError:
17-
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
18-
# simplifies the following tests. Without it, the amount of test code
19-
# increases significantly, with most of the additional code handling
20-
# the asyncio set up.
21-
from unittest import TestCase
22-
23-
class IsolatedAsyncioTestCase(TestCase):
24-
def run(self, result=None):
25-
self.skipTest(
26-
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
27-
)
28-
29-
3014
import os
31-
from unittest import mock
15+
from unittest import IsolatedAsyncioTestCase, mock
3216

3317
import grpc
34-
import pytest
3518

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

5235

53-
@pytest.mark.asyncio
5436
class TestAioClientInterceptorFiltered(TestBase, IsolatedAsyncioTestCase):
5537
def setUp(self):
5638
super().setUp()

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_client_interceptor_hooks.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
try:
15-
from unittest import IsolatedAsyncioTestCase
16-
except ImportError:
17-
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
18-
# simplifies the following tests. Without it, the amount of test code
19-
# increases significantly, with most of the additional code handling
20-
# the asyncio set up.
21-
from unittest import TestCase
22-
23-
class IsolatedAsyncioTestCase(TestCase):
24-
def run(self, result=None):
25-
self.skipTest(
26-
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
27-
)
28-
14+
from unittest import IsolatedAsyncioTestCase
2915

3016
import grpc
31-
import pytest
3217

3318
from opentelemetry.instrumentation.grpc import GrpcAioInstrumentorClient
3419
from opentelemetry.test.test_base import TestBase
@@ -54,7 +39,6 @@ def response_hook_with_exception(_span, _response):
5439
raise Exception() # pylint: disable=broad-exception-raised
5540

5641

57-
@pytest.mark.asyncio
5842
class TestAioClientInterceptorWithHooks(TestBase, IsolatedAsyncioTestCase):
5943
def setUp(self):
6044
super().setUp()

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import asyncio
15-
16-
try:
17-
from unittest import IsolatedAsyncioTestCase
18-
except ImportError:
19-
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
20-
# simplifies the following tests. Without it, the amount of test code
21-
# increases significantly, with most of the additional code handling
22-
# the asyncio set up.
23-
from unittest import TestCase
24-
25-
class IsolatedAsyncioTestCase(TestCase):
26-
def run(self, result=None):
27-
self.skipTest(
28-
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
29-
)
30-
15+
from unittest import IsolatedAsyncioTestCase
3116

3217
import grpc
3318
import grpc.aio
34-
import pytest
3519

3620
import opentelemetry.instrumentation.grpc
3721
from opentelemetry import trace
@@ -97,7 +81,6 @@ async def run_with_test_server(
9781
return resp
9882

9983

100-
@pytest.mark.asyncio
10184
class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
10285
async def test_instrumentor(self):
10386
"""Check that automatic instrumentation configures the interceptor"""

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor_filter.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
try:
15-
from unittest import IsolatedAsyncioTestCase
16-
except ImportError:
17-
# unittest.IsolatedAsyncioTestCase was introduced in Python 3.8. It's use
18-
# simplifies the following tests. Without it, the amount of test code
19-
# increases significantly, with most of the additional code handling
20-
# the asyncio set up.
21-
from unittest import TestCase
22-
23-
class IsolatedAsyncioTestCase(TestCase):
24-
def run(self, result=None):
25-
self.skipTest(
26-
"This test requires Python 3.8 for unittest.IsolatedAsyncioTestCase"
27-
)
28-
14+
from unittest import IsolatedAsyncioTestCase
2915

3016
import grpc
3117
import grpc.aio
32-
import pytest
3318

3419
from opentelemetry import trace
3520
from opentelemetry.instrumentation.grpc import (
@@ -68,7 +53,6 @@ async def run_with_test_server(
6853
return resp
6954

7055

71-
@pytest.mark.asyncio
7256
class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
7357
async def test_instrumentor(self):
7458
"""Check that automatic instrumentation configures the interceptor"""

0 commit comments

Comments
 (0)