From 39ac957c37c85a5cbf2e8b386fa0819e288dd5ec Mon Sep 17 00:00:00 2001 From: Artem Shelkovnikov Date: Wed, 5 Jul 2023 14:30:16 +0200 Subject: [PATCH 1/4] WIP --- pytest.ini | 8 ++++++++ setup.cfg | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 pytest.ini delete mode 100644 setup.cfg diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..7a806009b --- /dev/null +++ b/pytest.ini @@ -0,0 +1,8 @@ +[pytest] +asyncio_mode = auto +addopts = + -v +filterwarnings = + error + ignore:.*urllib3.contrib.pyopenssl.*:DeprecationWarning:botocore.* + ignore::DeprecationWarning:aiogoogle.* diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6a56fd2e1..000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[tools:pytest] -asyncio_mode = auto From c2a11e37466fa56aca2dcf60be17123479933d95 Mon Sep 17 00:00:00 2001 From: Artem Shelkovnikov Date: Thu, 6 Jul 2023 11:35:12 +0200 Subject: [PATCH 2/4] WIP 2 --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 7a806009b..891b21cef 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,4 +5,4 @@ addopts = filterwarnings = error ignore:.*urllib3.contrib.pyopenssl.*:DeprecationWarning:botocore.* - ignore::DeprecationWarning:aiogoogle.* + ignore:Inheritance class AiohttpSession from ClientSession is discouraged:DeprecationWarning From e3af0cca17a3324daf93bc894cc5aa8f8d5e5bee Mon Sep 17 00:00:00 2001 From: Artem Shelkovnikov Date: Fri, 14 Jul 2023 18:55:18 +0200 Subject: [PATCH 3/4] Ignore one more thing --- pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest.ini b/pytest.ini index 891b21cef..afe5ebeac 100644 --- a/pytest.ini +++ b/pytest.ini @@ -6,3 +6,4 @@ filterwarnings = error ignore:.*urllib3.contrib.pyopenssl.*:DeprecationWarning:botocore.* ignore:Inheritance class AiohttpSession from ClientSession is discouraged:DeprecationWarning + ignore:Inheritance class RetryableAiohttpSession from ClientSession is discouraged:DeprecationWarning From 58f2803019ca08fb226b488500dcc4f7f2ea3fd7 Mon Sep 17 00:00:00 2001 From: Artem Shelkovnikov Date: Thu, 10 Aug 2023 18:30:31 +0200 Subject: [PATCH 4/4] Fix more warnings + unclosed session for Slack --- pytest.ini | 9 +++++++++ tests/sources/test_slack.py | 17 +++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pytest.ini b/pytest.ini index afe5ebeac..acc54c487 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,6 +4,15 @@ addopts = -v filterwarnings = error +; botocore has this warning that is reported by them to be irrelevant ignore:.*urllib3.contrib.pyopenssl.*:DeprecationWarning:botocore.* +; latest main of aioresponses does not have this problem, but current package uses deprecated pkg_resources API + ignore:.*pkg_resources.*:DeprecationWarning +; SQLAlchemy uses deprecated APIs internally + ignore:.*dbapi().*:DeprecationWarning +; aiogoogle inherits on top of AioHttpSession, which is not recommended by aiohttp ignore:Inheritance class AiohttpSession from ClientSession is discouraged:DeprecationWarning +; aiogoogle inherits on top of RetryableAioHttpSession, which is not recommended by aiohttp ignore:Inheritance class RetryableAiohttpSession from ClientSession is discouraged:DeprecationWarning +; pytest may generate its own warnings in some situations, such as improper usage or deprecated features. + ignore::pytest.PytestUnraisableExceptionWarning diff --git a/tests/sources/test_slack.py b/tests/sources/test_slack.py index 1b2b9e744..9fee6a08d 100644 --- a/tests/sources/test_slack.py +++ b/tests/sources/test_slack.py @@ -192,12 +192,17 @@ async def test_slack_data_source_get_docs(slack_data_source, mock_responses): channels_response = [{"id": "1", "name": "channel1", "is_member": True}] messages_response = [{"text": "message1", "type": "message", "ts": 123456}] - slack_client = AsyncMock() - slack_client.list_users = AsyncIterator(users_response) - slack_client.list_channels = AsyncIterator(channels_response) - slack_client.list_messages = AsyncIterator(messages_response) - slack_client.close = AsyncMock() - slack_data_source.slack_client = slack_client + # A bit weird, but Slack connector actually inits client in its __init__ + # So we need to close it before redefining + original_client = slack_data_source.slack_client + await original_client.close() + + mock_client = AsyncMock() + mock_client.list_users = AsyncIterator(users_response) + mock_client.list_channels = AsyncIterator(channels_response) + mock_client.list_messages = AsyncIterator(messages_response) + mock_client.close = AsyncMock() + slack_data_source.slack_client = mock_client docs = [] async for doc, _ in slack_data_source.get_docs():