Closed
Description
Hi,
I just ran into this - if you make a fixture method async
, it is run with a different self
, so you can't set attributes on self
and read them in test methods. Here is a simple snippet to reproduce the problem:
import pytest
pytestmark = pytest.mark.asyncio
class TestAsyncFixture:
@pytest.fixture #(autouse = True)
async def setup(self):
# await self.client._handle_ws_request(self.payment_start_request)
self.some_attr = 'value'
print()
print('in fixture')
print(self)
print(self.__dict__)
async def test_response(self, setup):
print('in test')
print(self) # different object
print(self.__dict__) # some_attr missing
At first, I thought this only concerns autouse
fixtures, but now I tried using it without autouse
and it has the same problem. Is this a known issue, or is it supposed to work?
I'm using
python 3.8.3
pytest 6.1.2
pytest-asyncio 0.14.0
Btw, thanks for this great library, I'm using it heavily and it's been of great help.
Metadata
Metadata
Assignees
Labels
No labels