-
I have put together a MWE gist at https://gist.github.com/LewisGaul/126049eec2911a5d557285cff0e3799e to illustrate the behaviour in question. To summarise:
Problems/concerns/questions:
Does anyone have any thoughts on the approach taken here, or suggestions for how to improve things? Any best practices I've missed? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Uncovered flawA problem with this approach has been uncovered where the first testcase cannot be skipped using Possible workaroundsDummy testcaseOne possible approach would be to always create a dummy testcase, inserting it at the beginning of The downside of this is that there would always be a dummy testcase showing up in the results... Perhaps it can be filtered out from results using more pytest hooks, but this all starts to feel quite hacky. Decorate testcasesInstead of marking testcases with their required features (e.g. One apparent problem with this approach is that the decorator needs access to the resources required to perform the feature check, encapsulated in the This means that the decorator can define the testcase wrapper function to depend on the ConclusionI'm increasingly feeling that this plugin setup should just be done in the My previous concern about doing this in
I still feel a bit uneasy about this... However, the fact that all tests will run in the context of the host (e.g. the VM) it seems less of an obvious fit with fixtures. We could make it so that if I'm still hopeful of some thoughts from someone with more familiarity with pytest than me! |
Beta Was this translation helpful? Give feedback.
-
@nicoddemus From your comment above, can I take it implicitly from absence of disagreement that you agree with the following conclusions I'm arriving at?
|
Beta Was this translation helpful? Give feedback.
@nicoddemus From your comment above, can I take it implicitly from absence of disagreement that you agree with the following conclusions I'm arriving at?
pytest_sessionstart()
(orpytest_runtestloop()
) rather than an autouse fixture in the case where it must run before all other fixtures.pytest_collection_modifyitems()
and a per-test autouse fixture.