-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Parametrized fixture content depends on test function order. #5693
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
the output seems correct to me -- a |
Hi asottile, Could you please tell me, where I am wrong in my understanding:
Thank's. |
This is correct, but your fixture doesn't have parameters (the |
You're right it is not a Fixture problem, but a SubRequest bug:
A Subrequest without parameter must not have the same param_index as the first param in a list and should not have a param_index at all, otherwise FixtureDef.execute will return the cached value instead than calling hook.pytest_fixture_setup.
A quick fix could be:
Hope it helps ;-) |
I don't think that's right, but if you think it will fix the problem please propose a PR so it can be discussed there |
Could you please elaborate why you don't think that's right. |
the fixture has no |
So how do you explain indirect=True ? |
that only makes sense with |
Indirect is supposed to work with all scopes |
@RonnyPfannschmidt won't that cause all fixtures of all scopes to constantly be recreated whenever using |
No it's seems to make sense with all scopes except the 'function', as the 'function' scope is the easier to manage, your data is not shared by anyone. |
My understanding, is the fixture is recreated when the cache does not contains the requested param_index.
|
which would be always (unless your params is of length 1, which is not a useful
|
So, if we are in line, the fixture is created for each parameter as soon as his value is not in the cache, and the teardown is called for the one that "was" in the cached, whatever the scope. |
yes, which would essentially demote all fixtures to |
Not really, only all fixtures that are called by functions indirect parameter. |
not sure what you mean by address space, there's only one address space per process |
the |
Yes, it is also why they do not use the same 'address space'.
|
the general correct term for that is |
@RonnyPfannschmidt |
i wont in near future, im still on my hiatus fro general project work |
Thank's guys for your time, it was a nice tchat. As you can see below, it fixes at least the described problem.
I attached the file with modifications from 3173815, and also the test file. Regards, |
Fixture parametrized at the function definition, parameter scope='class'
When the same fixture (scope='class') is used by 2 functions:
Result:
function2 gets the ids of the first parameter, however it receives the default value.
The fixture is not called for the first parameter, the 'slot' seems to be already used by the default value.
But, if your reverse the call order, every test passes.
Code:
Result:
System info:
Linux4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: