

When you execute your notebook, you can preview variables in the Variables tab of the Jupyter tool window.īy default, variables are loaded asynchronously. This functionality is available only for local Jupyter server kernels. When you stop the server and change the server or kernel, you have to execute all cells with dependencies again, because execution results are valid for the current server session only. To execute all code cells in your notebook, click on the notebook toolbar or press Ctrl + Shift + Alt + Enter. In case of any errors, expand the Traceback node to preview the complete error message. When the execution is done, the cell remains in the edit mode, so that you can modify it, if needed, and keep experimenting. If a cell relies on some code in another cell, that cell should be executed first.

When executing one cell at a time, mind code dependencies. Shift+Enter: Runs the current cell and select the cell below it. Use the following smart shortcuts to quickly run the code cells: Note that when you work with local notebooks, you don’t need to launch any Jupyter server in advance: just execute any cell and the server will be launched. You can execute the code of the notebook cells in many ways using the icons on the notebook toolbar and cell toolbars, commands of the code cell context menu (right-click the code cell to open it), and the Run commands of the main menu. Point and run a debugger to inspect the state of the program to find cluesĪbout a possible bug.Run and debug Jupyter notebook code cells If a test fails it is often useful to halt the test case execution at some verbosity adjust the verbosity of the output (higher values = more verbose output). exit=False argument prevents unittest from shutting down the notebook kernel. We need the argv= argument, because we run the tests from a notebook and not form a command line. The tests use assert methods to check for an expected result.


One ore more tests that are implemented with methods whose names start with Test case is created by subclassing unittest.TestCase. The following code snippet contains a test case for the add() function. ItĪllows for more complex testing scenarios than doctest, but also requires to Looks and works similar to the unit testing frameworks in other languages. If we remove the verbose=True argument the output will be more concise.ĭoctest is very simple to use and suits well for writing simple test cases.įor more complicated test cases Python provides a full featured unit testing
