copy#

copy(*files: str, src: str | None = None, dst: str | None = None, when: str | dict[str, str] | None = None) None#

Copy files from the source directory into the execution directory.

Usage#

.pyt:

import canary
canary.directives.copy(*files, when=...)
canary.directives.copy(src=..., dst=..., when=...)

.vvt:

#VVT: copy (rename, options=..., platforms=..., parameters=..., testname=...) : files ...

Parameters#

  • files: File names to copy

  • src: Source file to copy

  • dst: Copy src to this destination

  • when: Restrict processing of the directive to this condition

The when expression is limited to the following conditions:

  • testname: Restrict processing of the directive to this test name

  • platforms: Restrict processing of the directive to certain platform or platforms

  • options: Restrict processing of the directive to command line -o options

  • parameters: Restrict processing of the directive to certain parameter names and values

Note

The files positional arguments and src,dst keyword arguments are mutually exclusive.

Examples#

Copy files input.txt and helper.py from the source directory to the execution directory

import canary
canary.directives.copy("input.txt", "helper.py")
#VVT: copy : input.txt helper.py

Copy files file1.txt and file2.txt from the source directory to the execution directory and rename them

import canary
canary.directives.copy(src="file1.txt", dst="file1_copy.txt")
canary.directives.copy(src="file2.txt", dst="file2_copy.txt")
#VVT: copy (rename) : file1.txt,file1_copy.txt file2.txt,file2_copy.txt

Copy files spam.txt and eggs.txt from the source directory to the execution directory if the parameter breakfast=spam or breakfast=eggs, respectively

import canary
canary.directives.parameterize("breakfast", ("spam", "eggs"))
canary.directives.copy("spam.txt", when={"parameters": "breakfast=spam"})
canary.directives.copy("eggs.txt", when={"parameters": "breakfast=eggs"})
#VVT: parameterize : breakfast = spam eggs
#VVT: copy (parameters='breakfast=spam') : spam.txt
#VVT: copy (parameters='breakfast=eggs') : eggs.txt