Skip to content

Commit

Permalink
Reproduce and fix #196
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Mar 13, 2019
1 parent 2c5c7e5 commit cd4cc48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jupytext/metadata_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/test_metadata_filter.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

0 comments on commit cd4cc48

Please sign in to comment.