skipif#
- skipif(arg: bool, *, reason: str) None#
Conditionally skip tests
Usage#
.pyt:import canary canary.directives.skipif(arg, *, reason)
.vvt:#VVT: skipif : python_expressionParameters#
arg: IfTrue, the test will be skipped.reason: The reason the test is being skipped.
.vvt Parameters#
python_expression: String that is evaluated and cast to abool. If the result isTruethe test will be skipped.
Examples#
import sys import canary canary.directives.skipif( sys.platform == "Darwin", reason="Test does not run on Apple" )
#VVT: skipif (reason=Test does not run on Apple) : sys.platform == "Darwin"will skip the test if run on Apple hardware.
If
reasonis not defined,canaryreports the reason as"python_expression evaluated to True".Checking module availability#
A test may be skipped if a module is not importable by using the
importablefunction.importable(module_name)evaluates toTrueifmodule_namecan be imported otherwise,False. For example,#VVT: skipif : not importable("numpy")would skip the test if
numpywas not available.Evaluation namespace#
python_expressionis evaluated in a minimal namespace consisting of theosmodule,sysmodule, andimportablefunction.