You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indirect session fixture reordering not working as expected #8914
λ pytest .tmp\test_fix_session.py -sq
prepare setup with 'dina'
Test1 done
.
prepare setup with 'mor'
Test2 done
.
prepare setup with 'dina'
Test3 done
.
3 passed in 0.02s
We would expect it to reorder the tests to [test_1, test_3, test_2] so the fixture would execute only twice, instead of 3 times as it is doing now, so definitely looks like a bug (unless I'm missing something).
changed the title [-]Indirect session fixture / item reordering issue[/-][+]Indirect session fixture reordering issue not working as expected[/+]on Jul 15, 2021
changed the title [-]Indirect session fixture reordering issue not working as expected[/-][+]Indirect session fixture reordering not working as expected[/+]on Jul 15, 2021
@nicoddemus This issue hit me as well, hopefully I found the root cause and a possible fix, see this commit
Reordering test items only took parameter indexes into account. This
works fine for direct parametrization. But for indirect parametrization,
the parameter index is always 0, and therefore every item went into the
same argkey group.
Now also add the parameter value to the argkey. This is enough
information to establish different argkey groups and make the grouping
algorithm work.
The output from your minimal reproducer is now as expected
prepare setup with 'dina'
Test1 done
Test3 done
prepare setup with 'mor'
Test2 done
but the change makes 3 tests fail (test_parameters_without_eq_semantics, test_parameters_without_eq_semantics, test_parametrize_issue634). I've not yet looked at them in detail.
Could you please give some short feedback? If you think I'm on the right track, I'll try to understand and fix the regression and open a PR here.
Activity
[-]Indirect session fixture / item reordering issue[/-][+]Indirect session fixture reordering issue not working as expected[/+][-]Indirect session fixture reordering issue not working as expected[/-][+]Indirect session fixture reordering not working as expected[/+]Formartha commentedon Jul 15, 2021
symonk commentedon Jul 31, 2021
I'm gonna have a look into this one next on my hit list, I've read the other thread for all the context and will start debugging soon
Consider param index and value for item reordering
haxtibal commentedon Nov 27, 2021
@nicoddemus This issue hit me as well, hopefully I found the root cause and a possible fix, see this commit
The output from your minimal reproducer is now as expected
but the change makes 3 tests fail (
test_parameters_without_eq_semantics,test_parameters_without_eq_semantics,test_parametrize_issue634). I've not yet looked at them in detail.Could you please give some short feedback? If you think I'm on the right track, I'll try to understand and fix the regression and open a PR here.
nicoddemus commentedon Nov 28, 2021
Hi @haxtibal, that's great! I looked at the code and it makes sense.
The failing tests are about making sure that pytest works even if the argvalues can't compare with
==(raise an error for example).I think a solution is to return a wrapper instead of the actual object, something like:
And then use it like this:
Feel free to open a PR even if incomplete, we can discuss this over the code. 👍
Fix reordering of indiretly parameterized fixture
Fix reordering of indiretly parameterized fixture
Fix reordering of indiretly parameterized fixture
Fix test reordering for indirect parameterization
haxtibal commentedon Nov 29, 2021
Thank's for your suggestions @nicoddemus ! We can switch over to #9350 now.
Fix test reordering for indirect parameterization
Add and adapt tests
Add and adapt tests
Fix test reordering for indirect parameterization
Add and adapt tests
Add and adapt tests
Add and adapt tests
Add and adapt tests
Add and adapt tests
Add and adapt tests