nbclient.tests package

Submodules

nbclient.tests.base module

class nbclient.tests.base.NBClientTestsBase(methodName='runTest')

Bases: unittest.case.TestCase

build_notebook(with_json_outputs=False)

Build a notebook in memory for use with NotebookClient tests

build_resources()

Build an empty resources dictionary.

classmethod merge_dicts(*dict_args)

nbclient.tests.fake_kernelmanager module

class nbclient.tests.fake_kernelmanager.FakeCustomKernelManager(**kwargs)

Bases: jupyter_client.manager.AsyncKernelManager

client(*args, **kwargs)

Create a client configured to connect to our kernel

expected_methods = {'__init__': 0, 'client': 0, 'start_kernel': 0}
async start_kernel(*args, **kwargs)

Starts a kernel on this host in a separate process.

If random ports (port=0) are being used, this method must be called before the channels are created.

Parameters

**kw (optional) – keyword arguments that are passed down to build the kernel_cmd and launching the kernel (e.g. Popen kwargs).

nbclient.tests.test_client module

class nbclient.tests.test_client.AsyncMock(*args, **kw)

Bases: unittest.mock.Mock

class nbclient.tests.test_client.TestExecute(methodName='runTest')

Bases: nbclient.tests.base.NBClientTestsBase

Contains test functions for execute.py

maxDiff = None
test_allow_errors()

Check that conversion halts if allow_errors is False.

test_cleanup_kernel_client()
test_constructor()
test_custom_kernel_manager()
test_disable_stdin()

Test disabling standard input

test_empty_kernel_name
test_empty_path()

Can the kernel be started when the path is empty?

test_execute_function()
test_force_raise_errors()

Check that conversion halts if the force_raise_errors traitlet on NotebookClient is set to True.

test_kernel_death_after_timeout()

Check that an error is raised when the kernel is_alive is false after a cell timed out

test_kernel_death_during_execution()

Check that an error is raised when the kernel is_alive is false during a cell execution.

test_populate_language_info()
test_process_message_wrapper()
test_reset_kernel_client()
test_timeout()

Check that an error is raised when a computation times out

test_timeout_func()

Check that an error is raised when a computation times out

test_widgets()

Runs a test notebook with widgets and checks the widget state is saved.

class nbclient.tests.test_client.TestRunCell(methodName='runTest')

Bases: nbclient.tests.base.NBClientTestsBase

Contains test functions for NotebookClient.execute_cell

test_allow_error_names(executor, cell_mock, message_mock)
test_allow_errors(executor, cell_mock, message_mock)
test_busy_message(executor, cell_mock, message_mock)
test_clear_output_message(executor, cell_mock, message_mock)
test_clear_output_wait_message(executor, cell_mock, message_mock)
test_clear_output_wait_then_message_message(executor, cell_mock, message_mock)
test_clear_output_wait_then_update_display_message(executor, cell_mock, message_mock)
test_deadline_exec_reply(executor, cell_mock, message_mock)
test_deadline_iopub(executor, cell_mock, message_mock)
test_display_data_message(executor, cell_mock, message_mock)
test_display_data_same_id_message(executor, cell_mock, message_mock)
test_display_data_without_id_message(executor, cell_mock, message_mock)
test_error_and_error_status_messages(executor, cell_mock, message_mock)
test_error_message(executor, cell_mock, message_mock)
test_error_message_only(executor, cell_mock, message_mock)
test_eventual_deadline_iopub(executor, cell_mock, message_mock)
test_execute_input_message(executor, cell_mock, message_mock)
test_execute_result_message(executor, cell_mock, message_mock)
test_execute_result_with_display_message(executor, cell_mock, message_mock)
test_execution_count_message(executor, cell_mock, message_mock)
test_execution_count_message_ignored_on_override(executor, cell_mock, message_mock)
test_execution_count_with_stream_message(executor, cell_mock, message_mock)
test_idle_message(executor, cell_mock, message_mock)
test_message_for_wrong_parent(executor, cell_mock, message_mock)
test_no_source(executor, cell_mock, message_mock)
test_non_code_cell(executor, cell_mock, message_mock)
test_raises_exception_tag(executor, cell_mock, message_mock)
test_stream_messages(executor, cell_mock, message_mock)
test_unknown_comm_message(executor, cell_mock, message_mock)
test_update_display_data_message(executor, cell_mock, message_mock)
test_update_display_data_mismatch_id_message(executor, cell_mock, message_mock)
test_update_display_data_without_id_message(executor, cell_mock, message_mock)
test_widget_comm_buffer_message(executor, cell_mock, message_mock)
test_widget_comm_message(executor, cell_mock, message_mock)
nbclient.tests.test_client.assert_notebooks_equal(expected, actual)
async nbclient.tests.test_client.async_run_notebook(filename, opts, resources=None)

Loads and runs a notebook, returning both the version prior to running it and the version after running it.

nbclient.tests.test_client.make_async(mock_value)
nbclient.tests.test_client.normalize_base64(b64_text)
nbclient.tests.test_client.normalize_output(output)

Normalizes outputs for comparison.

nbclient.tests.test_client.notebook_resources()

Prepare a notebook resources dictionary for executing test notebooks in the files folder.

nbclient.tests.test_client.prepare_cell_mocks(*messages, reply_msg=None)

This function prepares a executor object which has a fake kernel client to mock the messages sent over zeromq. The mock kernel client will return the messages passed into this wrapper back from preproc.kc.iopub_channel.get_msg callbacks. It also appends a kernel idle message to the end of messages.

nbclient.tests.test_client.run_notebook(filename, opts, resources=None)

Loads and runs a notebook, returning both the version prior to running it and the version after running it.

nbclient.tests.test_client.run_notebook_wrapper(args)
nbclient.tests.test_client.test_async_parallel_notebooks(capfd, tmpdir)

Two notebooks should be able to be run simultaneously without problems.

The two notebooks spawned here use the filesystem to check that the other notebook wrote to the filesystem.

nbclient.tests.test_client.test_execution_timing()

Compare the execution timing information stored in the cell with the actual time it took to run the cell. Also check for the cell timing string format.

nbclient.tests.test_client.test_many_async_parallel_notebooks(capfd)

Ensure that when many IPython kernels are run in parallel, nothing awful happens.

Specifically, many IPython kernels when run simultaneously would encounter errors due to using the same SQLite history database.

nbclient.tests.test_client.test_many_parallel_notebooks(capfd)

Ensure that when many IPython kernels are run in parallel, nothing awful happens.

Specifically, many IPython kernels when run simultaneously would encounter errors due to using the same SQLite history database.

nbclient.tests.test_client.test_parallel_notebooks(capfd, tmpdir)

Two notebooks should be able to be run simultaneously without problems.

The two notebooks spawned here use the filesystem to check that the other notebook wrote to the filesystem.

nbclient.tests.test_client.test_start_new_kernel_history_file_setting()
nbclient.tests.test_client.test_startnewkernel_with_kernelmanager()
nbclient.tests.test_client.test_synchronous_setup_kernel()

Module contents