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: nbformat.notebooknode.NotebookNode, resources: dict, index: int) → Tuple[nbformat.notebooknode.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: nbformat.notebooknode.NotebookNode, resources: dict, index: int) → Tuple[nbformat.notebooknode.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: nbformat.notebooknode.NotebookNode, resources: dict, index: int) → Tuple[nbformat.notebooknode.NotebookNode, dict][source]

Merge all stream outputs with shared names into single streams.

This ensure deterministic outputs.

Adapted from: https://github.com/computationalmodelling/nbval/blob/master/nbval/plugin.py.

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[source]

Get a post-processors for an entry point name.