Questions tagged [pytest-asyncio]

pytest-asyncio is a pytest plugin that facilitates testing asyncio code by providing helper fixtures and markers.

pytest-asyncio is a pytest plugin that provides several fixtures and markers that help testing asyncio code more easily. These help for example to test asyncio event loops, or to use test functions as asyncio coroutines.

Reference:

82 questions
0
votes
0 answers

how to change or check the order of the tests using pytest-asyncio

I'm using pytest-asyncio and can't find any documentation on how to ensure the order of the files running? For example if I have test_user.py and test_item.py and want test_user to run first, is there a way to do that?
foobar8675
  • 1,215
  • 3
  • 16
  • 26
0
votes
1 answer

attribute error: 'nonetype' object has no attribute 'empty' for async await

class a(self): async def x(self, p1, p2): await connection.fetch(p1) .... return df async def y(self, p3, p4): df = await self.x(x1, x2) if not df.empty: # code How to write a test method for y()? After mock of…
pooh_go
  • 1
  • 2
0
votes
1 answer

Testing Asyncio with Pytest: How to test a try-except block by mocking the event loop?

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 from the source, the relevant code looks like: #…
0
votes
1 answer

Combine python asyncio with pyee Event Emitter

I am trying use the AsyncIOEventEmitter from the pyee library without success. For some reason the emitted event "Hi" never reaches the async_handler to complete the asyncio future. I also did not find proper examples online. Additionally I tried…
Daniel P.
  • 369
  • 3
  • 12
0
votes
1 answer

Django-Channels 2 Communicator receive_output() doesn't work

I have a basic Consumer that receives messages from the websocket and then broadcasts those messages to a channel specified in the message. consumers.py class BasicConsumer(AsyncJsonWebsocketConsumer): async def receive_json(self, content,…
AbrahamCoding
  • 780
  • 9
  • 13
0
votes
2 answers

How can I adjust the number of threads with pytest + xdist?

To run parallel tests on mobile devices, I use pytest + xdist. I want to run as many threads as I have connected devices, no more. I pass "-n 4" as command line argument, but I can't change it after test launch if I need 2 threads, not 4. How can I…
lunin
  • 51
  • 6
0
votes
1 answer

tornado_json unit testing async methods

I'm trying to set up a unit test for a tornado_json web app. I'm trying to test a post handler, but I'm failing miserably as the fetch method seems to return an _asyncio.Future object, which never seems to complete/have a result set. I've tried to…
Conor
  • 535
  • 2
  • 8
  • 16
1 2 3 4 5
6