Session Ready
Exercise

Parametrize

Docstring examples are great, because they are included in Sphinx documentation and testable with doctest, but now we are ready to take our testing to the next level with pytest.

Writing pytest tests

  • is less cumbersome than writing docstring examples (no need for >>> or ...)
  • allows us to leverage awesome features like the parametrize decorator.

The arguments we will pass to parametrize are

  • a name for the list of arguments and
  • the list of arguments itself.

In this exercise, we will define a test_nbuild() function to pass three different file types to the nbuild() function and confirm that the output notebook contains the input file in its first cell.

We will use a custom function called show_test_output() to see the test output.

Instructions
100 XP
  • Add the parametrize decorator to one of the strings that we will save as a test file called test_nbuild.py.
  • Pass the argument set to the test_nbuild() function.