depends_on#
- depends_on(arg: str, when: str | dict[str, str] | None = None, expect: int | None = None, result: str | None = None) None#
Require that test
argrun before this test.Usage#
.pyt:import canary canary.directives.depends_on(name, when=..., expect=None, result=None)
.vvt:#VVT: depends on (result=..., expect=..., options=..., platforms=..., testname=...) : argParameters#
arg: The test that should run before this test. Wildcards are allowed.when: Restrict processing of the directive to this conditionresult: Control whether or not this test runs based on the result of the dependent test. By default, a test will run if its dependencies pass or diff.expect: How many dependencies to expect.
The
whenexpression is limited to the following conditions:testname: Restrict processing of the directive to this test nameplatforms: Restrict processing of the directive to certain platform or platformsoptions: Restrict processing of the directive to command line-ooptionsparameters: Restrict processing of the directive to certain parameter names and values
Examples#
Run
spamifbazpasses or diffs..pyt:# spam.pyt import canary canary.directives.depends_on("baz") def test(): self = canary.testinstance baz = self.dependencies[0] print(f"baz's results can be found in {baz.working directory}")
.vvt:# spam.vvt # VVT: depends on: baz import vvtest_util as vvt def test(): working directory = vvt.DEPDIRS[0] print(f"baz's results can be found in {working directory}")
Run
spamregardless ofbaz’s result:.pyt:# spam.pyt import canary canary.directives.depends_on("baz", result="*") def test(): self = canary.testinstance baz = self.dependencies[0] print(f"baz's results can be found in {baz.working directory}")
.vvt:# spam.vvt # VVT: depends on (result=*) : baz import vvtest_util as vvt def test(): working directory = vvt.DEPDIRS[0] print(f"baz's results can be found in {working directory}")
spamdepends only on the serialbaztest:.pyt:# spam.pyt import canary canary.directives.depends_on("baz.cpus=1") def test(): self = canary.testinstance baz = self.dependencies[0] print(f"baz's results can be found in {baz.working directory}")
.vvt:# spam.vvt # VVT: depends on: baz.np=1 import vvtest_util as vvt def test(): working directory = vvt.DEPDIRS[0] print(f"baz's results can be found in {working directory}")