-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raise error for loop if Python 3.10 (#261)
* raise error for loop * update sample * adams comments * adams comments * fix * update impl * add loop props * update test * create folder * comment test and add later * add async loop test to async samples * remove unnecessary imports
- Loading branch information
Showing
11 changed files
with
157 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import sys | ||
import pytest | ||
|
||
import asyncio | ||
from uamqp.async_ops.mgmt_operation_async import MgmtOperationAsync | ||
from uamqp.async_ops.receiver_async import MessageReceiverAsync | ||
from uamqp.authentication.cbs_auth_async import CBSAsyncAuthMixin | ||
from uamqp.async_ops.sender_async import MessageSenderAsync | ||
from uamqp.async_ops.client_async import ( | ||
AMQPClientAsync, | ||
SendClientAsync, | ||
ReceiveClientAsync, | ||
ConnectionAsync, | ||
) | ||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.skipif(sys.version_info < (3, 10), reason="raise error if loop passed in >=3.10") | ||
async def test_error_loop_arg_async(): | ||
with pytest.raises(ValueError) as e: | ||
AMQPClientAsync("fake_addr", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
client_async = AMQPClientAsync("sb://resourcename.servicebus.windows.net/") | ||
assert len(client_async._internal_kwargs) == 0 # pylint:disable=protected-access | ||
|
||
with pytest.raises(ValueError) as e: | ||
SendClientAsync("fake_addr", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
client_async = SendClientAsync("sb://resourcename.servicebus.windows.net/") | ||
assert len(client_async._internal_kwargs) == 0 # pylint:disable=protected-access | ||
|
||
with pytest.raises(ValueError) as e: | ||
ReceiveClientAsync("fake_addr", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
client_async = ReceiveClientAsync("sb://resourcename.servicebus.windows.net/") | ||
assert len(client_async._internal_kwargs) == 0 # pylint:disable=protected-access | ||
|
||
with pytest.raises(ValueError) as e: | ||
ConnectionAsync("fake_addr", sasl='fake_sasl', loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
|
||
with pytest.raises(ValueError) as e: | ||
MgmtOperationAsync("fake_addr", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
|
||
with pytest.raises(ValueError) as e: | ||
MessageReceiverAsync("fake_addr", "session", "target", "on_message_received", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
|
||
with pytest.raises(ValueError) as e: | ||
MessageSenderAsync("fake_addr", "source", "target", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
|
||
async def auth_async_loop(): | ||
auth_async = CBSAsyncAuthMixin() | ||
with pytest.raises(ValueError) as e: | ||
await auth_async.create_authenticator_async("fake_conn", loop=asyncio.get_event_loop()) | ||
assert "no longer supports loop" in e | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(auth_async_loop()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.