Skip to content

Commit

Permalink
Explicit name for the patch that prevents inserting Jupytext's versio…
Browse files Browse the repository at this point in the history
…n number

#279
  • Loading branch information
mwouts committed Jul 9, 2019
1 parent 15605d9 commit f5d18d4
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 77 deletions.
8 changes: 3 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@


@pytest.fixture
def header_insert_and_check_version_number_patch():
m = mock.patch('jupytext.header.INSERT_AND_CHECK_VERSION_NUMBER', False)
m.start()
yield m
m.stop()
def no_jupytext_version_number():
with mock.patch('jupytext.header.INSERT_AND_CHECK_VERSION_NUMBER', False):
yield
16 changes: 8 additions & 8 deletions tests/test_active_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_all(ext, header_insert_and_check_version_number_patch):
def test_active_all(ext, no_jupytext_version_number):
nb = jupytext.reads(HEADER[ext] + ACTIVE_ALL[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_ALL[ext], jupytext.writes(nb, ext))
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_active_all(ext, header_insert_and_check_version_number_patch):

@skip_if_dict_is_not_ordered
@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_ipynb(ext, header_insert_and_check_version_number_patch):
def test_active_ipynb(ext, no_jupytext_version_number):
nb = jupytext.reads(HEADER[ext] + ACTIVE_IPYNB[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_IPYNB[ext], jupytext.writes(nb, ext))
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_active_ipynb(ext, header_insert_and_check_version_number_patch):

@skip_if_dict_is_not_ordered
@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_ipynb_rmd_using_tags(ext, header_insert_and_check_version_number_patch):
def test_active_ipynb_rmd_using_tags(ext, no_jupytext_version_number):
nb = jupytext.reads(HEADER[ext] + ACTIVE_IPYNB_RMD_USING_TAG[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_IPYNB_RMD_USING_TAG[ext], jupytext.writes(nb, ext))
Expand All @@ -124,7 +124,7 @@ def test_active_ipynb_rmd_using_tags(ext, header_insert_and_check_version_number


@skip_if_dict_is_not_ordered
def test_active_ipynb_rspin(header_insert_and_check_version_number_patch):
def test_active_ipynb_rspin(no_jupytext_version_number):
nb = jupytext.reads(ACTIVE_IPYNB_RSPIN['.R'], 'R:spin')
assert len(nb.cells) == 1
compare(ACTIVE_IPYNB_RSPIN['.R'], jupytext.writes(nb, 'R:spin'))
Expand All @@ -151,7 +151,7 @@ def test_active_ipynb_rspin(header_insert_and_check_version_number_patch):

@skip_if_dict_is_not_ordered
@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_py_ipynb(ext, header_insert_and_check_version_number_patch):
def test_active_py_ipynb(ext, no_jupytext_version_number):
nb = jupytext.reads(HEADER[ext] + ACTIVE_PY_IPYNB[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_PY_IPYNB[ext], jupytext.writes(nb, ext))
Expand All @@ -178,7 +178,7 @@ def test_active_py_ipynb(ext, header_insert_and_check_version_number_patch):

@skip_if_dict_is_not_ordered
@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_py_r_ipynb(ext, header_insert_and_check_version_number_patch):
def test_active_py_r_ipynb(ext, no_jupytext_version_number):
nb = jupytext.reads(HEADER[ext] + ACTIVE_PY_R_IPYNB[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_PY_R_IPYNB[ext], jupytext.writes(nb, ext))
Expand All @@ -202,7 +202,7 @@ def test_active_py_r_ipynb(ext, header_insert_and_check_version_number_patch):

@skip_if_dict_is_not_ordered
@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_rmd(ext, header_insert_and_check_version_number_patch):
def test_active_rmd(ext, no_jupytext_version_number):
nb = jupytext.reads(HEADER[ext] + ACTIVE_RMD[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_RMD[ext], jupytext.writes(nb, ext))
Expand All @@ -228,7 +228,7 @@ def test_active_rmd(ext, header_insert_and_check_version_number_patch):

@skip_if_dict_is_not_ordered
@pytest.mark.parametrize('ext', ['.Rmd', '.py', '.R'])
def test_active_not_include_rmd(ext, header_insert_and_check_version_number_patch):
def test_active_not_include_rmd(ext, no_jupytext_version_number):
nb = jupytext.reads(ACTIVE_NOT_INCLUDE_RMD[ext], ext)
assert len(nb.cells) == 1
compare(ACTIVE_NOT_INCLUDE_RMD[ext], jupytext.writes(nb, ext))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_escape_magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_markdown_image_is_not_magic():
assert not is_magic('# ![Image name](image.png', 'python')


def test_multiline_python_magic(header_insert_and_check_version_number_patch):
def test_multiline_python_magic(no_jupytext_version_number):
nb = new_notebook(cells=[new_code_cell("""%load_ext watermark
%watermark -u -n -t -z \\
-p jupytext -v
Expand Down
4 changes: 2 additions & 2 deletions tests/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_header_to_metadata_and_cell_metadata():
assert pos == len(lines)


def test_metadata_and_cell_to_header(header_insert_and_check_version_number_patch):
def test_metadata_and_cell_to_header(no_jupytext_version_number):
metadata = {'jupytext': {'mainlanguage': 'python'}}
nb = new_notebook(
metadata=metadata,
Expand All @@ -83,7 +83,7 @@ def test_metadata_and_cell_to_header(header_insert_and_check_version_number_patc
assert lines_to_next_cell is None


def test_metadata_and_cell_to_header2(header_insert_and_check_version_number_patch):
def test_metadata_and_cell_to_header2(no_jupytext_version_number):
nb = new_notebook(cells=[new_markdown_cell(source="Some markdown\ntext")])
header, lines_to_next_cell = metadata_and_cell_to_header(nb, {}, get_format_implementation('.md'), '.md')
assert header == []
Expand Down
Loading

0 comments on commit f5d18d4

Please sign in to comment.