From dc937efd01eb0a4033d14ce497c263ac908dbd9e Mon Sep 17 00:00:00 2001 From: AN Long Date: Sun, 25 Feb 2024 18:03:24 +0800 Subject: [PATCH] Fix deprecated usage of pytest.warns --- tests/test_aio.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_aio.py b/tests/test_aio.py index c1243c1..d88ac18 100644 --- a/tests/test_aio.py +++ b/tests/test_aio.py @@ -348,9 +348,13 @@ async def _make_client(warning=None, **kwargs): is emitted (if any) and that the patch is properly applied by consuming the RuntimeError. """ - with pytest.warns(warning),\ - pytest.raises(RuntimeError): # Consume error - await make_aio_client(addressbook.AddressBookService, **kwargs) + if warning: + with pytest.warns(warning),\ + pytest.raises(RuntimeError): # Consume error + await make_aio_client(addressbook.AddressBookService, **kwargs) + else: + with pytest.raises(RuntimeError): # Consume error + await make_aio_client(addressbook.AddressBookService, **kwargs) def _given_timeout(self): """Get the timeout provided to TAsyncSocket."""