[feat] Add syntax for running functions after dependency resolution #951
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides a mechanism around the low-level
getdep()function that is used to access information on the dependencies of a test. The syntax follows the paradigm of the@run_beforeand@run_afterdecorators as introduced in #920. The following shows a more concrete example:The
@require_depswill bind all arguments of the decorated function to the corresponding test dependencies by name. In the above example, theT0argument will be bound to theT0test, so that its information can be retrieved when the function is executed. More precisely, each argument of the function (exceptself) is bound tofunctools.partial(self.getdep, arg_name). This allows to access a specific a test case of the target dependency as in the example below:When no environment is passed to the bound argument, the
self.current_environis assumed.All functions that require dependencies to be executed after dependency resolution will be executed first after the
setupphase and before any other function that is set to run aftersetupusing the@run_after('setup')decorator. You may also attach a function that requires dependencies to a different pipeline stage using as usual the@run_beforeor@run_afterdecorators as follows:The only requirement is that the
@require_depsdecorator is the innermost one. Of course, you can attach a function that requires dependencies to run before thesetup()method, in which a runtime error will be generated.Fixes UES-540.