enable#

enable(*args: bool, when: str | dict[str, str] | None = None) None#

Explicitly mark a test to be enabled (or not)

Usage#

.pyt:

import canary
canary.directives.enable(arg, when=...)

.vvt:

#VVT: enable (options=..., platforms=..., testname=...) : arg

Parameters#

  • arg: Optional (default: True). If True, enable the test. If False, disable the test

  • 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

Examples#

Explicitly disable a test

import canary
canary.directives.enable(False)
#VVT: enable : false

Enable the test if the platform name is not “ATS”

import canary
canary.directives.enable(True, when="platforms='not ATS'")
#VVT: enable (platform="not ATS") : true

More examples:

import canary
canary.directives.enable(True, when="testname=foo platform='Darwin or Linux'")
canary.directives.enable(True, when="platform='not Windows' options='not debug'")
canary.directives.enable(False, when="testname=foo")

The above examples are equivalent to:

import canary
canary.directives.enable(True, when={"testname": "foo", "platform": "Darwin or Linux"})
canary.directives.enable(True, when={"platform": "not Windows", "options": "not debug"})
canary.directives.enable(False, when={"testname": "foo"})

The vvt equivalent are

#VVT: enable (testname=foo, platform="Darwin or Linux") : true
#VVT: enable (platform="not Windows", options="not debug") : true
#VVT: enable (testname=foo) : false