testname#
- testname(arg: str) None#
Set the name of a test to one different from the filename and/or define multiple test names (multiple test instances) in the same file.
Usage#
.pyt:import canary canary.directives.name(arg)
.vvt:testname : arg
Parameters#
arg: The alternative test name.
Examples#
For the test file
a.pytcontainingimport canary canary.directives.testname("spam") ...
a test instance with name “spam” would be created, even though the file is named
a.pyt.
testnamecan be called multiple times. Each call will create a new test instance with a different name, e.g..pyt:import canary canary.directives.testname("foo") canary.directives.testname("bar") def test(): self = canary.get_instance() if self.name == "foo": do_foo_stuff() elif self.name == "bar": do_bar_stuff()
.vvt:#VVT: testname : foo #VVT: testname : bar import vvtest_util as vvt def test(): if vvt.NAME == "foo": do_foo_stuff() elif vvt.NAME == "bar": do_bar_stuff()
This file would result in two tests: “foo” and “bar”.