From 66fbeb9ecf8e538b2eb5ea620770c6f17d498eb8 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 3 Jun 2020 17:26:19 -0700 Subject: [PATCH 1/2] bugfix for #811 --- aiobotocore/session.py | 6 +++--- tests/test_session.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/test_session.py diff --git a/aiobotocore/session.py b/aiobotocore/session.py index 07a1a29e..0f029f67 100644 --- a/aiobotocore/session.py +++ b/aiobotocore/session.py @@ -136,9 +136,9 @@ async def get_service_data(self, service_name, api_version=None): api_version=api_version ) service_id = EVENT_ALIASES.get(service_name, service_name) - self._events.emit('service-data-loaded.%s' % service_id, - service_data=service_data, - service_name=service_name, session=self) + await self._events.emit('service-data-loaded.%s' % service_id, + service_data=service_data, + service_name=service_name, session=self) return service_data async def get_available_regions(self, service_name, partition_name='aws', diff --git a/tests/test_session.py b/tests/test_session.py new file mode 100644 index 00000000..68a8088a --- /dev/null +++ b/tests/test_session.py @@ -0,0 +1,16 @@ +import pytest + + +@pytest.mark.moto +@pytest.mark.asyncio +async def test_get_service_data(session): + handler_called = False + + def handler(**kwargs): + nonlocal handler_called + handler_called = True + + session.register('service-data-loaded.s3', handler) + response = await session.get_service_data('s3') + + assert handler_called From 9096c2430f7ce4ed4877a152d3fd03bb9ceccb23 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 3 Jun 2020 18:00:09 -0700 Subject: [PATCH 2/2] flake fix --- tests/test_session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_session.py b/tests/test_session.py index 68a8088a..84e536b2 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -11,6 +11,6 @@ def handler(**kwargs): handler_called = True session.register('service-data-loaded.s3', handler) - response = await session.get_service_data('s3') + await session.get_service_data('s3') assert handler_called