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
Running pytest test_classes.py -k TestBar gives me
test_classes.py::TestBar::test_c SKIPPED (test_c depends on b) [ 66%]
I guess dependency names are global, and TestBar.test_b doesn't get to register itself because the name b is already taken. As a consequence, if I run both classes in the same run, TestBar::test_c is executed -- even if TestBar::test_b fails. Is there another naming pattern I should use?
If there is no solution right now, something like this would be great:
, where the dependency names for TestFoo.test_a and TestFoo.test_b would be TestFoo.a and TestFoo.b respectively, and for TestBar it would be TestBar.a and TestBar.b. It wouldn't be able to fix depends calls at runtime though. But since those can access their class dynamically, there might be a way to write them in an inheritance-cooperative manner.
Setting the scope of the dependency-call to class doesn't solve the problem, since non-overloaded functions like test_a and test_c in the original example will be called in a different class scope.
The text was updated successfully, but these errors were encountered:
I'm working around it right now with a rather involved solution, which also implements dependency-based ordering, because overloading methods in a child will move them to the front of the order in which pytest (or any other inspection) finds them in the class.
@RKrahl, I think you rejected proposals that would make this project more complex in the past. I'll make the PR anyway since similar features were requested by others as well, and if it's fine to be pulled I can add docs as well.
For the following example:
test_classes.py
Running
pytest test_classes.py -k TestBar
gives meI guess dependency names are global, and
TestBar.test_b
doesn't get to register itself because the nameb
is already taken. As a consequence, if I run both classes in the same run,TestBar::test_c
is executed -- even ifTestBar::test_b
fails. Is there another naming pattern I should use?If there is no solution right now, something like this would be great:
, where the dependency names for
TestFoo.test_a
andTestFoo.test_b
would beTestFoo.a
andTestFoo.b
respectively, and forTestBar
it would beTestBar.a
andTestBar.b
. It wouldn't be able to fixdepends
calls at runtime though. But since those can access their class dynamically, there might be a way to write them in an inheritance-cooperative manner.Setting the scope of the dependency-call to
class
doesn't solve the problem, since non-overloaded functions liketest_a
andtest_c
in the original example will be called in a different class scope.The text was updated successfully, but these errors were encountered: