-
Notifications
You must be signed in to change notification settings - Fork 162
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Things to check first
-
I have searched the existing issues and didn't find my bug already reported there
-
I have checked that my bug is still present in the latest release
AnyIO version
4.0.0
Python version
3.11.4
What happened?
I'm trying to use an fixture class method to initialize some data for tests and store it in attributes. With synchronous fixture everything works as expected, the filled attributes are available in the test methods. But attributes filled in async function are not available in test methods. This happens because different objects are passed as "self" for the fixture and the test method.
I found similar issue for pytest-asyncio which was fixed
How can we reproduce the bug?
import pytest
class TestSomething:
@pytest.fixture()
async def do_setup(self):
self.some_attr = 'value'
print()
print('in fixture')
print(self)
print(self.__dict__)
async def test_something(self, do_setup):
print()
print('in test')
print(self) # different object
print(self.__dict__) # some_attr missing
Output:
in fixture
<tests.test_anyio.TestSomething object at 0x107b0ca50>
{'some_attr': 'value'}
in test
<tests.test_anyio.TestSomething object at 0x107f06590>
{}
chbndrhnns
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working