pytest-asyncio Questions
2
I have been using unittest.IsolatedAsyncioTestCase to test my async methods. I have been making use of setUpClass and asyncSetUp to create a fixture, and asyncTearDown to cleanup. This is all worki...
Lucubration asked 11/4, 2023 at 16:40
1
I have tried everything I've been able to find, but I can't get tests to work when httpx AsyncClient is used.
I encountered two errors when running a test:
RuntimeError: This event loop is already...
Fibrosis asked 31/3, 2021 at 21:30
10
Solved
I have a test to verify an exception is thrown from an async response, which I'm using pytest-asyncio version 0.10.0 to run.
Code is basically:
class TestThis:
@pytest.mark.asyncio
def test_the...
Certes asked 4/4, 2020 at 1:27
4
Solved
How do I define async fixtures and use them in async tests?
The following code, all in the same file, fails miserably. Is the fixture called plainly by the test runner and not awaited?
@pytest.fi...
Maryammaryann asked 20/4, 2018 at 7:53
5
Solved
I am testing an async function that might get deadlocked. I tried to add a fixture to limit the function to only run for 5 seconds before raising a failure, but it hasn't worked so far.
Setup:
pi...
Cholla asked 15/4, 2019 at 7:56
3
Solved
I don't understand for which purposes the decorator @pytest.mark.asyncio can be used.
I've tried to run the following code snippet with pytest and pytest-asyncio plugin installed and it failed, so...
Contrive asked 12/8, 2019 at 13:11
3
I received the error
RuntimeError: Event loop is closed
each time I try to make more than one async call inside my test. I already tried to use all other suggestions from other Stack Overflow pos...
Incomprehension asked 13/7, 2022 at 3:13
2
Solved
When testing the following code
@pytest.mark.asynico
async def test_handle_DATA(mocker):
handle_mock = mocker.MagicMock()
envelope_mock = mocker.MagicMock(mail_from="Test@From", rcpt_to...
Refractor asked 28/4, 2019 at 18:17
3
Solved
I think the example below is a really common use case:
create a connection to a database once,
pass this connection around to test which insert data
pass the connection to a test which verifies ...
Bangs asked 21/5, 2019 at 10:47
2
I am trying to write some tests for my fastapi app
I am using the prisma-client-py for the database. I don't know if that changes anything
Everything works as they are supposed to apart from ever...
Hallo asked 22/6, 2022 at 11:59
2
Solved
I'm trying to build FastAPI application fully covered with test using python 3.9
For this purpose I've chosen stack:
FastAPI, uvicorn, SQLAlchemy, asyncpg, pytest (+ async, cov plugins), coverage a...
Medical asked 8/10, 2021 at 7:44
3
Solved
@pytest.fixture
def d_service():
c = DService()
return c
# @pytest.mark.asyncio # tried it too
async def test_get_file_list(d_service):
files = await d_service.get_file_list('')
print(files)
...
Hustle asked 18/11, 2021 at 6:55
0
Playing with a small FastAPI application but getting 'event loop closed' RuntimeError when running pytest against my endpoints.
I have some database operations like this using AsyncIOMotorClient:
a...
Dorina asked 25/7, 2022 at 19:20
1
I'm writing python tests with pytest and have some async code I want to test so I installed the pytest-asyncio plugin. The async code uses aiohttp and running the tests I get the following warning/...
Cynth asked 15/1, 2021 at 17:12
0
I have a simple echo server function. Everything works fine if I launch pytest with a single test, but if I launch it with two tests then the second one hangs on waiting for the server to start, an...
Preventive asked 25/10, 2021 at 6:48
1
Solved
I have two unit tests, if I run them one by one, they pass. If I run them at class level, one pass and the other one fails at response = await ac.post( with the error message: RuntimeError: Event l...
Malebranche asked 4/2, 2021 at 21:50
1
Solved
In a source code (source link here and WIP PR here) I am working with, I am trying to improve test coverage by testing a try-except block in a class' __init__ method.
Stripping off the extra code f...
Erminia asked 10/1, 2021 at 10:28
1
Solved
I'm using dbus for IPC. In order to have exactly one bus throughout the livetime of my program I'm using a singleton here. For the sake of demonstration I'm connecting to NetworkManager but that co...
Euratom asked 9/10, 2020 at 14:55
3
Solved
I would like to run several tests concurrently using asyncio (/curio/trio) and pytest, but I couldn't find any information on that. Do I need to schedule them myself? And if I do, is there a way to...
Gomuti asked 4/6, 2019 at 17:3
0
What I'm Doing
I'm learning aiohttp by building a REST api which I'm testing with Pytest (and its async and aiohttp plugins).
For my first test (I'm going with TDD from outset) I have the followi...
Barboza asked 23/2, 2020 at 14:36
1
© 2022 - 2024 — McMap. All rights reserved.