Skip to content

Plugin - API

plugin

Pytest plugin to collect jupyter Notebooks.

  • Identifies all cells which use the %%ipytest magic
  • adds the notebook, cell and any test functions to the collection tree
  • relies on pytest logic and configuration to identify test functions.

Known Issues:

  • No Assertion rewriting.

Cell

A collector for jupyter notebook cells.

pytest will recognise these cells as pytest.Modules and use standard collection on them as it would any other python module.

__repr__

__repr__() -> str

Don't duplicate the word "Cell" in the repr.

_reportinfo

_reportinfo() -> tuple[str, int, str | None]

Override pytest which checks .obj.__code__.co_filename == .path.

collect

collect() -> Generator[Function, None, None]

Replace the reportinfo method on the children, if present.

Notebook

A collector for jupyter notebooks.

collect

collect() -> Generator[Cell, None, None]

Yield Cells for all cells which contain tests.

pytest_collect_file

pytest_collect_file(
    file_path: Path, parent: Collector
) -> Notebook | None

Hook implementation to collect jupyter notebooks.