generator#
- class AbstractTestGenerator(root: str, path: str | None = None)#
Bases:
ABCThe AbstractTestCaseGenerator is an abstract object representing a test file that can generate test cases
- Parameters:
root – The base test directory, or file path if
pathis not givenpath – The file path, relative to root
To create a test generator, simply subclass
AbstractTestGeneratorand register the containing file as ancanaryplugin. The subclass will be added to the command registry and added to the set of available test generators.All
canarybuiltin generators are implemented as plugins.Examples:
from typing import Optional import canary class MyGenerator(canary.AbstractTestGenerator): file_patterns = ["*.suffix"] def describe(self, on_options: list[str] | None = None) -> str: ... def lock(self, on_options: list[str] | None = None) -> list[canary.TestCase]: ...
- file_patterns: ClassVar[tuple[str, ...]] = ()#
- classmethod factory(root: str, path: str | None = None) Self | None#
- classmethod matches(path: str) str | None#
Is the file at
patha test file?
- describe(on_options: list[str] | None = None) str#
Return a description of the test
- abstractmethod lock(on_options: list[str] | None = None) Sequence[UnresolvedSpec | ResolvedSpec]#
Expand parameters and instantiate concrete test cases
- Parameters:
on_options – User specified options used to filter tests. Test cases not matching
on_optionsshould be masked.
Notes
For further discussion on filtering tests see Filtering tests.
- asdict() dict[str, Any]#
- static validate(data) Any#
- static reconstruct(serialized: str) AbstractTestGenerator#
- serialize() str#
- static create(root: str, path: str | None = None) AbstractTestGenerator#
- info() dict[str, Any]#