Skip to content

Commit

Permalink
Ignore changes in the kernel display name
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Sep 8, 2021
1 parent 2341156 commit 08a7d11
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions jupytext/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 08a7d11

Please sign in to comment.