Skip to content

Commit

Permalink
Make tests fail on warnings; add some warnings to ignore list (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-shelkovnikov authored Aug 11, 2023
1 parent 1330bbb commit 260a26f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
18 changes: 18 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[pytest]
asyncio_mode = auto
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
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

17 changes: 11 additions & 6 deletions tests/sources/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 260a26f

Please sign in to comment.