Skip to content
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

Add "postrequisites" to fixtures - the inverse of a prerequisite #945

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

laundmo
Copy link
Contributor

@laundmo laundmo commented Nov 12, 2024

A postrequisite is a fixture dependency which specifies that the postrequisite should run after the source fixture.
This in turn results in the postrequisite running before the source fixture for on_success

If i write a fixture A, which only has a on_succes that should run after the on_success of B, i can't make B a __prerequisites__ as those are sorted for on_request. This means as a prerequisite, B.on_success will run after my A.on_success, not before.

__postrequisites__ simply reverses this relation. B being in __postrequisites__ on A is the same a A being in the __prerequisites__ of B - and in fact, internally this is how postrequisites are represented while building the Directed Acyclic Graph.

This PR switches the custom topological sort to use graphlib instead, as graphlib detects cycles. graphlib is a new stdlib module since python 3.9, so graphlib-backport is added as a dependency for compatability with older python versions.

@laundmo laundmo force-pushed the fixture_postrequisites branch from 7b3468a to 4506e6e Compare November 12, 2024 15:32
@mdipierro
Copy link
Contributor

At the technical level this is a good PR. But it adds a lot of complexity and cognitive load to the users. Why is this needed? Let's discuss on the group.

@laundmo
Copy link
Contributor Author

laundmo commented Nov 13, 2024

Well, in most cases it's relatively little extra, as prerequisites work the same way as before and most cases won't need postrequisites.

Perhaps I can revert some of the docs sections which mention postrequisites as they're truly only relevant in very few cases - mainly Template.

Template is also the main motivating factor: currently, there's no nice way to ensure a fixture is always available to Template, such as T (Translator) or flash which are often used in the layout and therefore a permanent dependency of Template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants