Test that cells with an empty ``source`` are skipped. Given a notebook with 4 cells, 3 of which have empty ``source``: When ``process_notebook`` is called, Then only the non-empty cell should appear in the output (1 block => 2 triple quotes).
(write_notebook: WriteNotebookFunc)
| 181 | |
| 182 | |
| 183 | def test_process_notebook_empty_cells(write_notebook: WriteNotebookFunc) -> None: |
| 184 | """Test that cells with an empty ``source`` are skipped. |
| 185 | |
| 186 | Given a notebook with 4 cells, 3 of which have empty ``source``: |
| 187 | When ``process_notebook`` is called, |
| 188 | Then only the non-empty cell should appear in the output (1 block => 2 triple quotes). |
| 189 | """ |
| 190 | expected_count = 2 |
| 191 | notebook_content = { |
| 192 | "cells": [ |
| 193 | {"cell_type": "markdown", "source": []}, |
| 194 | {"cell_type": "code", "source": []}, |
| 195 | {"cell_type": "raw", "source": []}, |
| 196 | {"cell_type": "markdown", "source": ["# Non-empty markdown"]}, |
| 197 | ], |
| 198 | } |
| 199 | nb_path = write_notebook("empty_cells.ipynb", notebook_content) |
| 200 | result = process_notebook(nb_path) |
| 201 | |
| 202 | assert result.count('"""') == expected_count, "Only one non-empty cell => 1 block => 2 triple quotes" |
| 203 | assert "# Non-empty markdown" in result |
| 204 | |
| 205 | |
| 206 | def test_process_notebook_invalid_cell_type(write_notebook: WriteNotebookFunc) -> None: |
nothing calls this directly
no test coverage detected