generator#
- flatten_unique(xss: list[list[str]]) list[str]#
- class AbstractSpecGenerator(root: str, path: str | None = None)#
Bases:
ABCThe AbstractTestGenerator is an abstract object representing a test file that can generate jobs
- 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.JobSpecIR]: ...
- 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[JobSpecIR | JobSpec]#
Expand parameters and instantiate concrete test jobs
- Parameters:
on_options – User specified options used to filter tests. Jobs 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) AbstractSpecGenerator#
- static create(root: str, path: str | None = None) AbstractSpecGenerator#
- info() dict[str, Any]#
- AbstractTestGenerator#
alias of
AbstractSpecGenerator