diff --git a/jupytext/metadata_filter.py b/jupytext/metadata_filter.py index 1b043402f..d54ca9aae 100644 --- a/jupytext/metadata_filter.py +++ b/jupytext/metadata_filter.py @@ -103,7 +103,7 @@ def apply_metadata_filters(user_filter, default_filter, actual_keys): # notebook default filter = only few metadata if default_filter.get('additional'): - if user_filter.get('excluded') == 'all': + if user_filter.get('additional') == 'all': return actual_keys.difference(user_filter.get('excluded')) return (actual_keys diff --git a/tests/test_metadata_filter.py b/tests/test_metadata_filter.py index 9b8b30eb4..db3785eb9 100644 --- a/tests/test_metadata_filter.py +++ b/tests/test_metadata_filter.py @@ -1,4 +1,5 @@ import pytest +from nbformat.v4.nbbase import new_notebook from jupytext import reads, writes from jupytext.metadata_filter import filter_metadata, metadata_filter_as_dict @@ -68,3 +69,16 @@ def test_cell_metadata_filter_is_updated(): text2 = writes(nb, 'Rmd') assert text.splitlines()[-3:] == text2.splitlines()[-3:] + + +def test_notebook_metadata_all(): + nb = new_notebook(metadata={'user_metadata': [1, 2, 3], + 'jupytext': {'notebook_metadata_filter': 'all'}}) + text = writes(nb, 'md') + assert 'user_metadata' in text + + +def test_notebook_metadata_none(): + nb = new_notebook(metadata={'jupytext': {'notebook_metadata_filter': '-all'}}) + text = writes(nb, 'md') + assert '---' not in text