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 'silver-acorn'
INFO: Selecting test cases based on runtime environment
INFO: Starting session 2026-04-21T15-34-28.346793
INFO: Starting process pool with max 2 workers
Job ID Status Queued Elapsed Rank
──────────────────────────────────────────────────────────────────────────────────────────────────────────
breakfast.dish=spam 7ade8ab SUBMITTED 2/4
breakfast.dish=spam 7ade8ab STARTED 0.3s 2/4
breakfast.dish=eggs 402d80b SUBMITTED 1/4
breakfast.dish=eggs 402d80b STARTED 0.3s 1/4
breakfast.dish=spam 7ade8ab PASS (SUCCESS) 0.3s 0.5s 2/4
breakfast.dish=eggs 402d80b PASS (SUCCESS) 0.3s 0.5s 1/4
lunch 78fa499 SUBMITTED 4/4
lunch 78fa499 STARTED 0.0s 4/4
breakfast.dish=ham edbd66f SUBMITTED 3/4
breakfast.dish=ham edbd66f STARTED 0.0s 3/4
lunch 78fa499 PASS (SUCCESS) 0.0s 0.2s 4/4
breakfast.dish=ham edbd66f PASS (SUCCESS) 0.0s 0.2s 3/4
INFO: 4/4 tests finished with status PASS
INFO: Finished session in 0.79 s. with returncode 0
INFO: Updating view at /home/docs/checkouts/readthedocs.org/user_builds/canary-wm/checkouts/release-26.4.16/src/canary/examples/TestResults