module ipythonhelper.unittest_notebook

Short summary

module pyquickhelper.ipythonhelper.unittest_notebook

Functions to test a notebook.

source on GitHub

Functions

function

truncated documentation

test_notebook_execution_coverage

Runs and tests a specific list of notebooks. The function raises an exception if the execution fails.

Documentation

Functions to test a notebook.

source on GitHub

pyquickhelper.ipythonhelper.unittest_notebook.test_notebook_execution_coverage(filename, name, folder, this_module_name, valid=None, copy_files=None, modules=None, filter_name=None, fLOG=<function noLOG>)[source][source]

Runs and tests a specific list of notebooks. The function raises an exception if the execution fails.

Parameters
  • filename – test filename (usually __file__)

  • name – substring to look into notebook filenames

  • folder – where to look for notebooks

  • valid – skip cells if valid is False, None for all valid

  • copy_files – files to copy before running the notebooks.

  • modules – list of extra dependencies (not installed), example: ['pyensae']

  • this_module_name – the module name being tested (as a string)

  • filter_name – None or function

  • fLOG – logging function

The function calls execute_notebook_list_finalize_ut which stores information about the notebooks execution. This will be later used to compute the coverage of notebooks. Modules pyquickhelper and jyquickhelper must be imported before calling this function. Example of a unit test calling this function:

from pyquickhelper.loghelper import fLOG
from pyquickhelper.ipythonhelper import test_notebook_execution_coverage
from pyquickhelper.pycode import add_missing_development_version
import src.mymodule


class TestFunctionTestNotebook(unittest.TestCase):

    def setUp(self):
        add_missing_development_version(["jyquickhelper"], __file__, hide=True)

    def test_notebook_example_pyquickhelper(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        folder = os.path.join(os.path.dirname(__file__), ".." , "..", "_doc", "notebooks")
        test_notebook_execution_coverage(__file__, "compare_python_distribution",
                                         folder, 'mymodule', fLOG=fLOG)

source on GitHub