pytest_notebook.post_processors module#

Plugins to post process notebooks.

All functions should take (notebook, resources) as input, and output a (new notebook, resources).

pytest_notebook.post_processors.beautifulsoup(cell: NotebookNode, resources: dict, index: int) Tuple[NotebookNode, dict][source]#

Format text/html and image/svg+xml outputs with beautiful-soup.

See: https://beautiful-soup-4.readthedocs.io.

pytest_notebook.post_processors.blacken_code(cell: NotebookNode, resources: dict, index: int) Tuple[NotebookNode, dict][source]#

Format python source code with black (see https://black.readthedocs.io).

pytest_notebook.post_processors.cell_preprocessor(function)[source]#

Wrap a function to be executed on all cells of a notebook.

The wrapped function should have these parameters:

cellNotebookNode cell

Notebook cell being processed

resourcesdictionary

Additional resources used in the conversion process.

indexint

Index of the cell being processed

pytest_notebook.post_processors.coalesce_streams(cell: NotebookNode, resources: dict, index: int) Tuple[NotebookNode, dict][source]#

Merge all stream outputs with shared names into single streams.

This ensure deterministic outputs.

Adapted from: computationalmodelling/nbval.

pytest_notebook.post_processors.document_processors()[source]#

Create formatted string of all preprocessor docstrings.

pytest_notebook.post_processors.list_processor_names()[source]#

List entry point names for post-processors.

pytest_notebook.post_processors.load_processor(name: str)[source]#

Get a post-processors for an entry point name.