# Path: aiobotocore/eventstream.py
# class AioEventStream(EventStream):
#     async def _create_raw_event_generator(self):
#         event_stream_buffer = EventStreamBuffer()
#         async for chunk, _ in self._raw_stream.iter_chunks():
#             event_stream_buffer.add_data(chunk)
#             for event in event_stream_buffer:
#                 yield event
# 
#     def __iter__(self):
#         raise NotImplementedError('Use async-for instead')
# 
#     def __aiter__(self):
#         return self.__anext__()
# 
#     async def __anext__(self):
#         async for event in self._event_generator:
#             parsed_event = self._parse_event(event)
#             if parsed_event:
#                 yield parsed_event
# 
#     async def get_initial_response(self):
#         try:
#             async for event in self._event_generator:
#                 event_type = event.headers.get(':event-type')
#                 if event_type == 'initial-response':
#                     return event
# 
#                 break
#         except StopIteration:
#             pass
#         raise NoInitialResponseError()


import asyncio
import pytest
import botocore.parsers
import aiobotocore.session
from contextlib import AsyncExitStack
from aiobotocore.eventstream import AioEventStream
    )

    events = []
    # {'Records': {'Payload': b'{"hello":"world"}\n'}}
    # {'Stats': {'Details': {'BytesScanned': 19,
    #                        'BytesProcessed': 19,
    #                        'BytesReturned': 18}}}
    # {'End': {}}
    async for event in event_stream:
        events.append(event)

    assert len(events) == 3
    event1, event2, event3 = events

    assert 'Records' in event1
    assert 'Stats' in event2
    assert 'End' in event3


@pytest.mark.moto
@pytest.mark.asyncio
async def test_eventstream_no_iter(s3_client):
    # These are the options passed to the EventStream class
    # during a normal run with botocore.
    operation_name = 'SelectObjectContent'
    outputshape = (s3_client._service_model.operation_model(operation_name)
                   .output_shape.members['Payload'])
    parser = botocore.parsers.EventStreamXMLParser()
    sr = FakeStreamReader(TEST_STREAM_DATA)


# Path: aiobotocore/eventstream.py
# class AioEventStream(EventStream):
#     async def _create_raw_event_generator(self):
#         event_stream_buffer = EventStreamBuffer()
#         async for chunk, _ in self._raw_stream.iter_chunks():
#             event_stream_buffer.add_data(chunk)
#             for event in event_stream_buffer:
#                 yield event
# 
#     def __iter__(self):
#         raise NotImplementedError('Use async-for instead')
# 
#     def __aiter__(self):
#         return self.__anext__()
# 
#     async def __anext__(self):
#         async for event in self._event_generator:
#             parsed_event = self._parse_event(event)
#             if parsed_event:
#                 yield parsed_event
# 
#     async def get_initial_response(self):
#         try:
#             async for event in self._event_generator:
#                 event_type = event.headers.get(':event-type')
#                 if event_type == 'initial-response':
#                     return event
# 
#                 break
#         except StopIteration:
#             pass
#         raise NoInitialResponseError()


# Path: tests/test_eventstreams.py
import asyncio
import pytest
import botocore.parsers
import aiobotocore.session
from contextlib import AsyncExitStack
from aiobotocore.eventstream import AioEventStream

    )

    events = []
    # {'Records': {'Payload': b'{"hello":"world"}\n'}}
    # {'Stats': {'Details': {'BytesScanned': 19,
    #                        'BytesProcessed': 19,
    #                        'BytesReturned': 18}}}
    # {'End': {}}
    async for event in event_stream:
        events.append(event)

    assert len(events) == 3
    event1, event2, event3 = events

    assert 'Records' in event1
    assert 'Stats' in event2
    assert 'End' in event3


@pytest.mark.moto
@pytest.mark.asyncio
async def test_eventstream_no_iter(s3_client):
    # These are the options passed to the EventStream class
    # during a normal run with botocore.
    operation_name = 'SelectObjectContent'
    outputshape = (s3_client._service_model.operation_model(operation_name)
                   .output_shape.members['Payload'])
    parser = botocore.parsers.EventStreamXMLParser()
    sr = FakeStreamReader(TEST_STREAM_DATA)


    event_stream = AioEventStream(