Sourcing rc scripts during test execution#
Some tests require a modified environment. When the required environment modifications are contained in rc files, canary can source the files prior to test execution. There are two ways to modify the environment by sourcing an rc file:
Through the
canary.shell.sourcecontext manager:import canary def test(): with canary.shell.source("filename"): # do work
Through the
canary.directives.source()directive:import canary canary.directives.source("filename", when=...) def test(): # do work
Note
Only sh compatible rc files are supported.