Replies: 1 comment
-
It turns out I messed up a bit when writing the original post's test code, and something got weird. The (edited original post to fix that) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
context and original state
I have a set of inter-dependent parametrized tests originally set up as follows. They respectively test:
Edit: original post had a mistake explained in first followup, confusing content was removed.
The tests can be run on several version, which nicely map to test parameters, and I am able to name each and every dependencies for
pytest-dependency
to ensure tests are run in correct order:trying to follow best practice
The Fixtures HOWTO makes a good point that my
test_firstboot
would be better with anautouse
fixture and 2 separate tests.Refactoring gives the following for "first boot" . Note the switch of the
what
parameter to "class" scope, which looks like a natural way to keep the related tests together.We can see all those tests have a single "Class" parent:
Wouldn't it make sense to have distinct
TestFirstboot
nodes, parametrized intoTestFirstboot[1]
andTestFirstboot[2]
?Having separate class nodes for different parameter sets, like
TestFirstboot[1]
andTestFirstboot[2]
, also seem to be necessary for any caching done at the class-fixture level: even when using the workaround, where they are different collected class nodes, we would need to get distinctnodeid
s for them.depending on such multiple-assert test
Now the question is, how to adjust the dependency of
test_upgrade
to get the same effect as the original version.Regardless of parameters,
pytest-dependency
currently only seems to support depending on tests, and although it can make sense to allow a dependency on a class in such a case with only effects-free tests, where it could be made an equivalent to "all tests collected below this node", it would not be reasonable to unable it systematically. Maybe such a behavior could be activated inpytest-dependency
through aneffect_free_tests
orallow_dependency
class marker?A workaround is to specify as dependency one of the tests in the class
wrapping up
Before opening any issues - did I miss any existing feature to get this working without any tool evolution? Does all of this make sense to others?
Beta Was this translation helpful? Give feedback.
All reactions