-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using async libraries with PyTest #3809
Comments
please try with |
Looking good on |
#3755 and similar where triggerd by code that was intended to trigger a deprecation |
So if I understand correctly |
@amit-traiana no , pytest introducing the deprecation triggers the issue (as we wrap a async fixture with a generator actually i just realized we dont handle async functions at all that way so bascially the more recent pytest release wraps stuff in a way thats unfortunate @nicoddemus ping on that just to cross-check if my understanding is correct |
Thanks for clearing it out @RonnyPfannschmidt . In that case, I think I'll revert back to 3.6.4 for now until @nicoddemus can comment on what can be done about it. Thank you! |
@amit-traiana sorry for the delay. This issue has been fixed by #3780 and was released in This is also a duplicate of #3774, although the description is completely different. 👍 |
Hello there @nicoddemus - No problem at all, I was happy with Thanks you! |
It is ok in |
Hello everyone!
I am experiencing inconsistent behaviour when using async/sync fixtures. Our tests using
pyppeteer
(Python wrapper around Google's Puppeteer library). Almost allpyppeteer
methods are async. A common code will look like so:So in order to be able to run async tests, I'm using
pytest-asyncio
(and there actually an integration bug betweenpytest-asyncio
andpyppeteer
. A bug was opened on thepytest-asyncio
that explains the issue). The above share a common code that should get executed before every test:and at the end of each test:
await browser.close()
So obviously, a fixture is needed here.
The above will work properly if using a normal fixture (like seen in the sftp client example on the official documentation), and while it's a bit confusing yield returns a value and not an iterator - there no problem with using the fixture. But unlike
yield
in a non-async fixture, the yield here will not return the value ofpage
, but instead will return an async-generator. So the following test will fail:with the following error:
AttributeError: 'async_generator' object has no attribute 'goto'
. The only way around it is to manually iterate over async generator so the test will look like so:It that the right way of doing it? because it seems a bit cumbersome and contradict how yield works on non-async methods.
Thanks!
The text was updated successfully, but these errors were encountered: