dev.tests#

Helper functions for tests.

Submodules#

Package Contents#

Classes#

Case

Notebook test case.

Caser

Notebook test case generator.

Functions#

init

Initialize test plot formats.

get_cached_nb_ns

Get cached notebook namespace.

parametrize_by_cases

Parametrize this test by cases.

clean_notebooks

Clean notebooks using pre-commit hooks.

Data#

NAMER

Random name sequence for case files.

API#

dev.tests.NAMER: collections.abc.Iterator[str]#

‘_RandomNameSequence(…)’

Random name sequence for case files.

dev.tests.init()#

Initialize test plot formats.

dev.tests.get_cached_nb_ns(
nb: str,
params: dev.tests.types.Params | None = None,
attributes: dev.tests.types.Attributes | None = None,
) types.SimpleNamespace#

Get cached notebook namespace.

class dev.tests.Case#

Notebook test case.

Args: stage: Notebook stage. suffix: Test ID suffix. params: Parameters to pass to the notebook.

stage: str#

None

Notebook stage.

id: str#

‘_’

Test ID suffix.

params: dict[str, Any]#

‘field(…)’

Parameters to pass to the notebook.

results: list[str]#

‘field(…)’

Additional results to get from the notebook.

marks: collections.abc.Sequence[pytest.Mark]#

‘field(…)’

Pytest marks.

clean_path: pathlib.Path | None#

‘field(…)’

Path to the cleaned notebook.

property path: pathlib.Path#

Notebook path.

property nb: str#

Notebook contents.

clean_nb() str#

Clean notebook contents.

dev.tests.parametrize_by_cases(
*cases: dev.tests.Case,
)#

Parametrize this test by cases.

class dev.tests.Caser#

Notebook test case generator.

exp: pathlib.Path#

None

cases: list[dev.tests.Case]#

‘field(…)’

__call__(
stage: str,
id: str = '_',
params: dict[str, Any] | None = None,
results: list[str] | None = None,
marks: collections.abc.Sequence[pytest.Mark] | None = None,
) dev.tests.Case#

Add case to experiment.

dev.tests.clean_notebooks(
*nbs: pathlib.Path | str,
)#

Clean notebooks using pre-commit hooks.