Skip to content

Commit 6baefbc

Browse files
authored
[EventHubs] skip tests if aiohttp not installed (Azure#40447)
1 parent 4786fc9 commit 6baefbc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

sdk/eventhub/azure-eventhub/tests/pyamqp_tests/asynctests/test_websocket_async.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ async def send_message(live_eventhub):
3333

3434

3535
@pytest.mark.asyncio
36-
@pytest.mark.skipif(sys.version_info < (3, 9), reason="Test requires Python 3.9 or higher")
36+
@pytest.mark.skipif(
37+
not pytest.importorskip("aiohttp", reason="aiohttp is required for this test"),
38+
reason="aiohttp is not installed"
39+
)
3740
async def test_event_hubs_client_web_socket_async(live_eventhub):
3841
uri = "sb://{}/{}".format(live_eventhub["hostname"], live_eventhub["event_hub"])
3942
sas_auth = _authentication_async.SASTokenAuthAsync(

sdk/eventhub/azure-eventhub/tests/pyamqp_tests/unittest/asynctests/test_websocket_exception_async.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import sys
12
import pytest
23
import asyncio
34
from unittest.mock import patch
4-
5-
import aiohttp
65
from azure.eventhub._pyamqp.aio._transport_async import WebSocketTransportAsync
76

87

98
# class WebsocketException(unittest.TestCase):
109
@pytest.mark.asyncio
10+
@pytest.mark.skipif(
11+
not pytest.importorskip("aiohttp", reason="aiohttp is required for this test"),
12+
reason="aiohttp is not installed"
13+
)
1114
async def test_websocket_aiohttp_exception_async():
15+
import aiohttp
1216
with patch.object(aiohttp.ClientSession, "ws_connect", side_effect=aiohttp.ClientOSError):
1317
transport = WebSocketTransportAsync(host="my_host")
1418
with pytest.raises(aiohttp.ClientOSError):

0 commit comments

Comments
 (0)