Add support for db fixture (test inside transaction) for asyncio tests
In using and debugging pytest-django with async tests & fixtures, I ended up hacking together a way to get the db fixture working by enabling the transaction in the sync to async executor thread in which async orm queries run.
This PR aims to integrate that hack as actual functionality into pytest-django.
The async work is done, I also worked to refine the sync side database access: not allowing db access to threads other than the main thread which is running the test (& transaction). That second part is causing some test failures I've yet been unable to fix on 3.9 & django 4.2, will try to fix or drop it from the PR.
edit: I managed to fix the issue with the test failures: my monkeypatches were dropping the self attribute. Ready for review.
Suggestions & feedback welcome.
@kingbuzzman CI and myself are now happy with where the branch is at, feel free to have a deeper look now.
@lode-braced can you please sync with main, there are new CI rules
@lode-braced can you please sync with
main, there are new CI rules
Done!
@kingbuzzman apologies for the silence, I've been on holiday. The PR should have addressed your remarks where possible, and I've removed the sync code, to be done in another PR once we get this one done.
Can you have another look and close topics as needed?
@kingbuzzman Is there anything you need/someone else I should ping to get this reviewed further?
Hey @lode-braced I haven't been ignoring you deliberately. I've been waiting for others to give some feedback, specially @bluetech
Hey, we're running in some similar issues with the combination of pytest-asyncio, pytest-django and pytest-xdist. Any idea when this PR can be expected to be reviewed/approved? Thanks!