Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing loop fixture with aiomisc 17 #24

Closed
mweinelt opened this issue Mar 5, 2023 · 2 comments
Closed

Missing loop fixture with aiomisc 17 #24

mweinelt opened this issue Mar 5, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@mweinelt
Copy link

mweinelt commented Mar 5, 2023

Long story short

loop fixture missing with aiomisc 17

Expected behavior

Tests should succeed.

Actual behavior

caio> ==================================== ERRORS ====================================
caio> __ ERROR at setup of test_operations_cancel_cleanly[caio.python_aio_asyncio] ___
caio> file /build/source/tests/test_asyncio_adapter.py, line 65
caio>   @aiomisc.timeout(3)
caio>   async def test_operations_cancel_cleanly(
caio>       tmp_path, async_context_maker, asyncio_exception_handler
caio>   ):
caio>       async with async_context_maker() as context:
caio>           with open(str(tmp_path / "temp.bin"), "wb+") as fp:
caio>               fd = fp.fileno()
caio> 
caio>               await context.write(b"\x00", fd, 1024**2 - 1)
caio>               assert os.stat(fd).st_size == 1024**2
caio> 
caio>               for _ in range(50):
caio>                   reads = [
caio>                       asyncio.create_task(context.read(2**16, fd, 2**16 * i))
caio>                       for i in range(16)
caio>                   ]
caio>                   _, pending = await asyncio.wait(
caio>                       reads, return_when=asyncio.FIRST_COMPLETED
caio>                   )
caio>                   for read in pending:
caio>                       read.cancel()
caio>                   if pending:
caio>                       await asyncio.wait(pending)
caio>                   asyncio_exception_handler.assert_not_called()
caio> file /build/source/tests/test_asyncio_adapter.py, line 54
caio>   @pytest.fixture
caio>   async def asyncio_exception_handler(loop):
caio>       handler = Mock(
caio>           side_effect=lambda _loop, ctx: _loop.default_exception_handler(ctx)
caio>       )
caio>       current_handler = loop.get_exception_handler()
caio>       loop.set_exception_handler(handler=handler)
caio>       yield handler
caio>       loop.set_exception_handler(current_handler)
caio> E       fixture 'loop' not found
caio> >       available fixtures: async_context_maker, asyncio_exception_handler, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, context_maker, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
caio> >       use 'pytest --fixtures [testpath]' for help on them.
caio> 
caio> /build/source/tests/test_asyncio_adapter.py:54
caio> =============================== warnings summary ===============================
caio> tests/test_asyncio_adapter.py::test_adapter[caio.python_aio_asyncio]
caio> tests/test_asyncio_adapter.py::test_bad_file_descritor[caio.python_aio_asyncio]
caio>   /nix/store/ma77c9gm2zbikjjgf3i6hs3rp9i13f2r-python3.10-pytest-7.2.1/lib/python3.10/site-packages/_pytest/python.py:184: PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped.
caio>   You need to install a suitable plugin for your async framework, for example:
caio>     - anyio
caio>     - pytest-asyncio
caio>     - pytest-tornasync
caio>     - pytest-trio
caio>     - pytest-twisted
caio>     warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid)))
caio> 
caio> -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
caio> =========================== short test summary info ============================
caio> ERROR tests/test_asyncio_adapter.py::test_operations_cancel_cleanly[caio.python_aio_asyncio]

Steps to reproduce

  1. Install aiomisc~=17
  2. Run the test suite

Environment info

platform linux -- Python 3.10.10, pytest-7.2.1, pluggy-1.0.0

and aiomisc 17.0.6

Additional info

@mosquito mosquito added the bug Something isn't working label Mar 6, 2023
@mosquito
Copy link
Owner

mosquito commented Mar 6, 2023

aiomisc-pytest is now a separate module

@mosquito
Copy link
Owner

@mweinelt fixes in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants