Establishing dependencies on specific test parameterizations#
Tests can depend on specific paramterizations of other tests.
Example#
The test lunch depends on breakfast, but only when dish="spam":
# Copyright NTESS. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: MIT
import canary
canary.directives.parameterize("dish", ("eggs", "ham", "spam"))
# Copyright NTESS. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: MIT
import sys
import canary
canary.directives.depends_on("breakfast.dish=spam")
def lunch() -> int:
instance = canary.get_instance()
assert instance.dependencies[0].family == "breakfast"
assert instance.dependencies[0].parameters.dish == "spam"
if __name__ == "__main__":
sys.exit(lunch())
$ canary run ./depends_on/parameter
INFO: Initializing empty canary workspace at .
INFO: Collecting generator files from depends_on/parameter
INFO: Instantiating generators from collected files
INFO: Generating test specs from generators
INFO: Searching for duplicated tests
INFO: Resolving test spec dependencies
INFO: Generated 4 test specs from 2 generators
INFO: Caching test specs
INFO: Created selection 'diligent-turtle'
INFO: Selecting test jobs based on runtime environment
INFO: Starting session 2026-06-04T20-43-15.386973
INFO: Starting process pool with max 1 workers
Job ID Status Elapsed Rank
────────────────────────────────────────────────────────────────────────────────────────────────
breakfast.dish=eggs 78da8bb SUBMITTED 1/4
breakfast.dish=eggs 78da8bb STARTED 1/4
breakfast.dish=eggs 78da8bb PASS (SUCCESS) 0.6s 1/4
breakfast.dish=spam 89ff548 SUBMITTED 2/4
breakfast.dish=spam 89ff548 STARTED 2/4
breakfast.dish=spam 89ff548 PASS (SUCCESS) 0.3s 2/4
breakfast.dish=ham 5855bf8 SUBMITTED 3/4
breakfast.dish=ham 5855bf8 STARTED 3/4
breakfast.dish=ham 5855bf8 PASS (SUCCESS) 0.3s 3/4
lunch 2d90bee SUBMITTED 4/4
lunch 2d90bee STARTED 4/4
lunch 2d90bee PASS (SUCCESS) 0.4s 4/4
INFO: 4/4 tests finished with status PASS
INFO: Finished session in 1.85 s. with returncode 0
INFO: Updating view at /home/docs/checkouts/readthedocs.org/user_builds/canary-wm/checkouts/latest/src/canary/examples/TestResults