-
Notifications
You must be signed in to change notification settings - Fork 159
ScopeMismatch error when adding fixture as parameter #68
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
Comments
Hello, unfortunately you always need the event_loop fixture, even if you don't ask for it explicitely (because you need it to run your test and fixtures). From the docs (a little buried I admit): All scopes are supported, but if you use a non-function scope you will need to redefine the event_loop fixture to have the same or broader scope. Async fixtures need the event loop, and so must have the same or narrower scope than the event_loop fixture. Try redefining the event_loop fixture like this:
|
Thanks for answer!
But when i remove all scopes params everything works fine. |
Hmm. Could you put together a small example so I can debug it? Simplest possible where the bug is visible, you can just await asyncio.sleep in the fixture. |
Okay, see this https://github.com/ddsl/simple-async-jwtauth |
Hi, I installed your example into a clean Python 3.6 virtualenv. Didn't get the ScopeMismatch errors, but I did get some warnings with request.addfinalizer. You don't need to use it though, I fixed it up over here (https://gist.github.com/Tinche/96457dedcb34ba6653373469371a95da) and it seems to work. Is this good for you? |
Thank you a lot. It didn't help but i think it is indecent to take so much time from someone for the sake of trivia. most likely the problem is in me rather than your code. |
Alright, if you want to continue just reopen :) |
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
Run test async using a wrapper for Cassandra python driver's future. The wrapper was suggested by a user and brought forward by @fruch. It's based on https://stackoverflow.com/a/49351069 . Redefine pytest event_loop fixture to avoid issues with fixtures with scope bigger than function (like keyspace). See pytest-dev/pytest-asyncio#68 Convert sample test_null to async. More useful test cases will come afterwards. Signed-off-by: Alejo Sanchez <[email protected]>
Run test async using a wrapper for Cassandra python driver's future. The wrapper was suggested by a user and brought forward by @fruch. It's based on https://stackoverflow.com/a/49351069 . Redefine pytest event_loop fixture to avoid issues with fixtures with scope bigger than function (like keyspace). See pytest-dev/pytest-asyncio#68 Convert sample test_null to async. More useful test cases will come afterwards. Signed-off-by: Alejo Sanchez <[email protected]>
Run test async using a wrapper for Cassandra python driver's future. The wrapper was suggested by a user and brought forward by @fruch. It's based on https://stackoverflow.com/a/49351069 . Redefine pytest event_loop fixture to avoid issues with fixtures with scope bigger than function (like keyspace). See pytest-dev/pytest-asyncio#68 Convert sample test_null to async. More useful test cases will come afterwards. Signed-off-by: Alejo Sanchez <[email protected]>
Run test async using a wrapper for Cassandra python driver's future. The wrapper was suggested by a user and brought forward by @fruch. It's based on https://stackoverflow.com/a/49351069 . Redefine pytest event_loop fixture to avoid issues with fixtures with scope bigger than function (like keyspace). See pytest-dev/pytest-asyncio#68 Convert sample test_null to async. More useful test cases will come afterwards. Signed-off-by: Alejo Sanchez <[email protected]>
Run test async using a wrapper for Cassandra python driver's future. The wrapper was suggested by a user and brought forward by @fruch. It's based on https://stackoverflow.com/a/49351069 . Redefine pytest event_loop fixture to avoid issues with fixtures with scope bigger than function (like keyspace). See pytest-dev/pytest-asyncio#68 Convert sample test_null to async. More useful test cases will come afterwards. Signed-off-by: Alejo Sanchez <[email protected]>
Run test async using a wrapper for Cassandra python driver's future. The wrapper was suggested by a user and brought forward by @fruch. It's based on https://stackoverflow.com/a/49351069 . Redefine pytest event_loop fixture to avoid issues with fixtures with scope bigger than function (like keyspace). See pytest-dev/pytest-asyncio#68 Convert sample test_null to async. More useful test cases will come afterwards. Signed-off-by: Alejo Sanchez <[email protected]>
I got a ScopeMismatch error when tried to add fixture to my test fucntion in a class when I add the scope parameter
(scope='class' or scope='module')
:My case:
And when i run it i get :
I tried to delete the event_loop param but it gave the same error but when i removed
scope
parameter from the fixture everithing worksThe text was updated successfully, but these errors were encountered: