# Path: azmq/containers.py
# class AsyncList(list, AsyncObject):
#     """
#     A list-like object that is asyncio-compatible.
#     """
#     def __init__(self, *items, **kwargs):
#         """
#         Instanciate a new `AsyncList` list with optional items.
# 
#         :param items: If provided, an iterable of items to fill the list with.
#         :param loop: The event loop the instance is associated with. Default
#             to the thread-local current asyncio event-loop.
#         """
#         list.__init__(self, *items)
#         AsyncObject.__init__(self, **kwargs)
#         self._empty = asyncio.Event(loop=self.loop)
#         self._not_empty = asyncio.Event(loop=self.loop)
#         self._change_futures = set()
#         self._refresh()
# 
#     def _refresh(self):
#         if self:
#             self._empty.clear()
#             self._not_empty.set()
#         else:
#             self._empty.set()
#             self._not_empty.clear()
# 
#         for future in self._change_futures:
#             if not future.done():
#                 future.set_result(None)
# 
#     def append(self, *args, **kwargs):
#         super().append(*args, **kwargs)
#         self._refresh()
# 
#     def remove(self, *args, **kwargs):
#         super().remove(*args, **kwargs)
#         self._refresh()
# 
#     def extend(self, *args, **kwargs):
#         super().extend(*args, **kwargs)
#         self._refresh()
# 
#     def clear(self, *args, **kwargs):
#         super().clear(*args, **kwargs)
#         self._refresh()
# 
#     def __setitem__(self, *args, **kwargs):
#         super().__setitem__(*args, **kwargs)
#         self._refresh()
# 
#     def pop(self, *args, **kwargs):
#         try:
#             return super().pop(*args, **kwargs)
#         finally:
#             self._refresh()
# 
#     def insert(self, *args, **kwargs):
#         super().insert(*args, **kwargs)
#         self._refresh()
# 
#     async def wait_not_empty(self):
#         """
#         Wait for the list to become non-empty.
#         """
#         await self._not_empty.wait()
# 
#     async def wait_empty(self):
#         """
#         Wait for the list to become empty.
#         """
#         await self._empty.wait()
# 
#     async def wait_change(self):
#         """
#         Wait for the list to change.
#         """
#         future = asyncio.Future(loop=self.loop)
#         self._change_futures.add(future)
#         future.add_done_callback(self._change_futures.discard)
#         await future
# 
#     def create_proxy(self):
#         """
#         Create a fair list proxy to the current instance.
# 
#         :returns: A `FairListProxy` instance.
#         """
#         return FairListProxy(self)


import asyncio
import pytest
from azmq.containers import AsyncList
"""
Unit tests for containers.
"""




async def assert_empty(l):
    await asyncio.wait_for(l.wait_empty(), 0)

    with pytest.raises(asyncio.TimeoutError):
        await asyncio.wait_for(l.wait_not_empty(), 0)


async def assert_non_empty(l):
    await asyncio.wait_for(l.wait_not_empty(), 0)

    with pytest.raises(asyncio.TimeoutError):
        await asyncio.wait_for(l.wait_empty(), 0)


def test_asynclist_list_likeness():
    al = AsyncList()
    al.append(4)
    al.extend([5, 6])
    assert al == [4, 5, 6]
    assert len(al) == 3

# Path: azmq/containers.py
# class AsyncList(list, AsyncObject):
#     """
#     A list-like object that is asyncio-compatible.
#     """
#     def __init__(self, *items, **kwargs):
#         """
#         Instanciate a new `AsyncList` list with optional items.
# 
#         :param items: If provided, an iterable of items to fill the list with.
#         :param loop: The event loop the instance is associated with. Default
#             to the thread-local current asyncio event-loop.
#         """
#         list.__init__(self, *items)
#         AsyncObject.__init__(self, **kwargs)
#         self._empty = asyncio.Event(loop=self.loop)
#         self._not_empty = asyncio.Event(loop=self.loop)
#         self._change_futures = set()
#         self._refresh()
# 
#     def _refresh(self):
#         if self:
#             self._empty.clear()
#             self._not_empty.set()
#         else:
#             self._empty.set()
#             self._not_empty.clear()
# 
#         for future in self._change_futures:
#             if not future.done():
#                 future.set_result(None)
# 
#     def append(self, *args, **kwargs):
#         super().append(*args, **kwargs)
#         self._refresh()
# 
#     def remove(self, *args, **kwargs):
#         super().remove(*args, **kwargs)
#         self._refresh()
# 
#     def extend(self, *args, **kwargs):
#         super().extend(*args, **kwargs)
#         self._refresh()
# 
#     def clear(self, *args, **kwargs):
#         super().clear(*args, **kwargs)
#         self._refresh()
# 
#     def __setitem__(self, *args, **kwargs):
#         super().__setitem__(*args, **kwargs)
#         self._refresh()
# 
#     def pop(self, *args, **kwargs):
#         try:
#             return super().pop(*args, **kwargs)
#         finally:
#             self._refresh()
# 
#     def insert(self, *args, **kwargs):
#         super().insert(*args, **kwargs)
#         self._refresh()
# 
#     async def wait_not_empty(self):
#         """
#         Wait for the list to become non-empty.
#         """
#         await self._not_empty.wait()
# 
#     async def wait_empty(self):
#         """
#         Wait for the list to become empty.
#         """
#         await self._empty.wait()
# 
#     async def wait_change(self):
#         """
#         Wait for the list to change.
#         """
#         future = asyncio.Future(loop=self.loop)
#         self._change_futures.add(future)
#         future.add_done_callback(self._change_futures.discard)
#         await future
# 
#     def create_proxy(self):
#         """
#         Create a fair list proxy to the current instance.
# 
#         :returns: A `FairListProxy` instance.
#         """
#         return FairListProxy(self)


# Path: tests/unit/test_containers.py
import asyncio
import pytest
from azmq.containers import AsyncList

"""
Unit tests for containers.
"""




async def assert_empty(l):
    await asyncio.wait_for(l.wait_empty(), 0)

    with pytest.raises(asyncio.TimeoutError):
        await asyncio.wait_for(l.wait_not_empty(), 0)


async def assert_non_empty(l):
    await asyncio.wait_for(l.wait_not_empty(), 0)

    with pytest.raises(asyncio.TimeoutError):
        await asyncio.wait_for(l.wait_empty(), 0)


def test_asynclist_list_likeness():
    al = AsyncList()
    al.append(4)
    al.extend([5, 6])
    assert al == [4, 5, 6]
    assert len(al) == 3

    assert al == AsyncList([4, 5, 6])