From 08a7d110f3a27e5caa6371154356c21020f62f2e Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Tue, 7 Sep 2021 22:12:13 +0200 Subject: [PATCH] Ignore changes in the kernel display name --- jupytext/compare.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jupytext/compare.py b/jupytext/compare.py index aacd0b253..fc7e9b049 100644 --- a/jupytext/compare.py +++ b/jupytext/compare.py @@ -66,13 +66,18 @@ def filtered_cell(cell, preserve_outputs, cell_metadata_filter): return filtered -def filtered_notebook_metadata(notebook): +def filtered_notebook_metadata(notebook, ignore_display_name=False): """Notebook metadata, filtered for metadata added by Jupytext itself""" metadata = filter_metadata( notebook.metadata, notebook.metadata.get("jupytext", {}).get("notebook_metadata_filter"), _DEFAULT_NOTEBOOK_METADATA, ) + + # The display name for the kernel might change (Quarto format on the CI) + if ignore_display_name: + metadata.get("kernelspec", {}).pop("display_name", None) + if "jupytext" in metadata: del metadata["jupytext"] return metadata @@ -149,9 +154,12 @@ def compare_notebooks( # Compare notebook metadata modified_metadata = False try: + ignore_display_name = ( + fmt.get("extension") == ".qmd" and allow_expected_differences + ) compare( - filtered_notebook_metadata(notebook_actual), - filtered_notebook_metadata(notebook_expected), + filtered_notebook_metadata(notebook_actual, ignore_display_name), + filtered_notebook_metadata(notebook_expected, ignore_display_name), ) except AssertionError as error: if raise_on_first_difference: