generator#

flatten_unique(xss: list[list[str]]) list[str]#
class AbstractSpecGenerator(root: str, path: str | None = None)#

Bases: ABC

The AbstractTestGenerator is an abstract object representing a test file that can generate jobs

Parameters:
  • root – The base test directory, or file path if path is not given

  • path – The file path, relative to root

To create a test generator, simply subclass AbstractTestGenerator and register the containing file as an canary plugin. The subclass will be added to the command registry and added to the set of available test generators.

All canary builtin 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 path a 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_options should 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