Closed Shulyaka closed 1 year ago
This makes me think you have some problem with interaction between tests that runs in a different order or possibly a sync/async problem.
Is there a reason that this is not defined as a pytest fixture?
Is there a reason that this is not defined as a pytest fixture?
No particular reason, I've done this before I learned about asyncio_mode = auto
.
I've just changed it to pytest but it made no difference.
This makes me think you have some problem with interaction between tests that runs in a different order or possibly a sync/async problem.
I am not experienced in this. How can I influence the order? Should I always add a sync test as the first test in each file so it could interpret the fixture as sync?
You generally cannot influence the order of testing for pytest. If you do this means that your tests aren't properly firewalled from each other. I would try to fix that rather than specifiying an order for your tests.
A cause of this could be sync/async issues across tests, which manifests in weird ways with homeassistant. See #155 as another example. This line seems like it might be problematic, note that you are calling this from a sync function that is never awaited:
Edit: Looking into this more, I'm not sure that this is correct interpretation, but this is the sort of mixup that could cause problems.
This is very strange. I've converted one of the tests to sync (https://github.com/Shulyaka/xbee_humidifier/commit/04045476a7ebe13f785e9aa0f53afdbc5ba1ebd2) and surprisingly it worked! Even other unaffected tests that were previously failing!
I've had an impression that I am allowed to mix sync/async fixtures and that pytest should automatically await the async ones.
I don't understand it, but I am ready to close this issue.
Thank you!
I'm not so sure that this is the right fix, but you might have confirmed that this is a sync/async issue somewhere in either your tests or your code.
For others who had a similar issue, I found using --asyncio-mode=auto on the commandline stopped the issue occurring. It seems this only works if you use asyncio only, no other async libs.
Hi! I am having a strange error on my local environment, but not on github CI, even though the software versions are the same. I am not able to find out the source of the error. I have
asyncio_mode = auto
in my setup.cfg and the following fixture in my conftest.py:And this is the error it gives me:
Some details on the environment: