From f5d18d4cb7830a0e9fd1ae7768ec0a442d6a91e3 Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Tue, 9 Jul 2019 23:57:07 +0200 Subject: [PATCH] Explicit name for the patch that prevents inserting Jupytext's version number #279 --- tests/conftest.py | 8 +-- tests/test_active_cells.py | 16 +++--- tests/test_escape_magics.py | 2 +- tests/test_header.py | 4 +- tests/test_mirror.py | 92 +++++++++++++++--------------- tests/test_read_simple_markdown.py | 16 ++---- tests/test_rmd_to_ipynb.py | 2 +- tests/test_trust_notebook.py | 4 +- 8 files changed, 67 insertions(+), 77 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index dcf92bfc5..e3df5d578 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/test_active_cells.py b/tests/test_active_cells.py index bcabea2e5..71e956ebb 100644 --- a/tests/test_active_cells.py +++ b/tests/test_active_cells.py @@ -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)) @@ -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)) @@ -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)) @@ -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')) @@ -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)) @@ -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)) @@ -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)) @@ -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)) diff --git a/tests/test_escape_magics.py b/tests/test_escape_magics.py index 5758799ca..21acab138 100644 --- a/tests/test_escape_magics.py +++ b/tests/test_escape_magics.py @@ -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 diff --git a/tests/test_header.py b/tests/test_header.py index 9cdb2db78..a329672af 100644 --- a/tests/test_header.py +++ b/tests/test_header.py @@ -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, @@ -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 == [] diff --git a/tests/test_mirror.py b/tests/test_mirror.py index 35eee7105..6b0fa3c19 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -22,7 +22,7 @@ def create_mirror_file_if_missing(mirror_file, notebook, fmt): jupytext.write(notebook, mirror_file, fmt=fmt) -def test_create_mirror_file_if_missing(tmpdir, header_insert_and_check_version_number_patch): +def test_create_mirror_file_if_missing(tmpdir, no_jupytext_version_number): py_file = str(tmpdir.join('notebook.py')) assert not os.path.isfile(py_file) create_mirror_file_if_missing(py_file, new_notebook(), 'py') @@ -83,44 +83,44 @@ def assert_conversion_same_as_mirror(nb_file, fmt, mirror_name, compare_notebook @pytest.mark.parametrize('nb_file', list_notebooks('julia') + list_notebooks('python') + list_notebooks('R')) -def test_script_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_script_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb', 'script_to_ipynb') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_julia')) -def test_ipynb_to_julia(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_julia(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'jl', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='many hash')) -def test_ipynb_to_python(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_python(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'py', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='')) -def test_ipynb_to_python_vim(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_python_vim(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, {'extension': '.py', 'cell_markers': '{{{,}}}'}, 'ipynb_to_script_vim_folding_markers') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='')) -def test_ipynb_to_python_vscode(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_python_vscode(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, {'extension': '.py', 'cell_markers': 'region,endregion'}, 'ipynb_to_script_vscode_folding_markers') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_R')) -def test_ipynb_to_R(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_R(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'R', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_R')) -def test_ipynb_to_r(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_r(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, '.low.r', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_m')) -def test_ipynb_to_m(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_m(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, '.m', 'ipynb_to_script') @@ -128,72 +128,72 @@ def test_ipynb_to_m(nb_file, header_insert_and_check_version_number_patch): [(nb_file, extension) for nb_file in list_notebooks('ipynb_scheme') for extension in ('ss', 'scm')]) -def test_ipynb_to_scheme(nb_file, extension, header_insert_and_check_version_number_patch): +def test_ipynb_to_scheme(nb_file, extension, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, extension, 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_clojure')) -def test_ipynb_to_clojure(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_clojure(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'clj', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_bash')) -def test_ipynb_to_bash(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_bash(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'sh', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_cpp')) -def test_ipynb_to_cpp(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_cpp(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'cpp', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_q')) -def test_ipynb_to_q(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_q(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'q', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_julia')) -def test_ipynb_to_julia_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_julia_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'jl:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_m')) -def test_ipynb_to_m_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_m_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'm:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='')) -def test_ipynb_to_python_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_python_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'py:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py')) -def test_ipynb_to_python_hydrogen(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_python_hydrogen(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'py:hydrogen', 'ipynb_to_hydrogen') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_R')) -def test_ipynb_to_R_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_R_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'R:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_R')) -def test_ipynb_to_r_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_r_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, '.low.r:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_R')) -def test_ipynb_to_R_spin(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_R_spin(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'R', 'ipynb_to_spin') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_R')) -def test_ipynb_to_r_spin(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_r_spin(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, '.low.r', 'ipynb_to_spin') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_cpp')) -def test_ipynb_to_cpp_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_cpp_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'cpp:percent', 'ipynb_to_percent') @@ -201,123 +201,123 @@ def test_ipynb_to_cpp_percent(nb_file, header_insert_and_check_version_number_pa [(nb_file, extension) for nb_file in list_notebooks('ipynb_scheme') for extension in ('ss', 'scm')]) -def test_ipynb_to_scheme_percent(nb_file, extension, header_insert_and_check_version_number_patch): +def test_ipynb_to_scheme_percent(nb_file, extension, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, '{}:percent'.format(extension), 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_clojure')) -def test_ipynb_to_clojure_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_clojure_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'clj:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_bash')) -def test_ipynb_to_bash_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_bash_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'sh:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_q')) -def test_ipynb_to_q_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_q_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'q:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('percent')) -def test_percent_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_percent_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb:percent', 'script_to_ipynb') @pytest.mark.parametrize('nb_file', list_notebooks('hydrogen')) -def test_hydrogen_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_hydrogen_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb:hydrogen', 'script_to_ipynb') @pytest.mark.parametrize('nb_file', list_notebooks('R_spin')) -def test_spin_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_spin_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb:spin', 'script_to_ipynb') @requires_sphinx_gallery @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='(raw|hash|frozen|magic|html|164|long)')) -def test_ipynb_to_python_sphinx(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_python_sphinx(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'py:sphinx', 'ipynb_to_sphinx') @requires_sphinx_gallery @pytest.mark.parametrize('nb_file', list_notebooks('sphinx')) -def test_sphinx_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_sphinx_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb:sphinx', 'sphinx_to_ipynb') @requires_sphinx_gallery @pytest.mark.parametrize('nb_file', list_notebooks('sphinx')) -def test_sphinx_md_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_sphinx_md_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, {'extension': '.ipynb', 'format_name': 'sphinx', 'rst2md': True}, 'sphinx-rst2md_to_ipynb', compare_notebook=True) @pytest.mark.parametrize('nb_file', list_notebooks('md')) -def test_md_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_md_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb', 'md_to_ipynb') @pytest.mark.parametrize('nb_file', list_notebooks('Rmd')) -def test_Rmd_to_ipynb(nb_file, header_insert_and_check_version_number_patch): +def test_Rmd_to_ipynb(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ipynb', 'Rmd_to_ipynb') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_all', skip='Calysto|66')) -def test_ipynb_to_Rmd(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_Rmd(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'Rmd', 'ipynb_to_Rmd') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_all', skip='Calysto')) -def test_ipynb_to_md(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_md(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'md', 'ipynb_to_md') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_idl')) -def test_ipynb_to_pro(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_pro(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'pro', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_idl')) -def test_ipynb_to_pro_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_pro_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'pro:percent', 'ipynb_to_percent') @requires_pandoc @pytest.mark.parametrize('nb_file', list_notebooks('ipynb', skip='(functional|Notebook with|flavors|invalid)')) -def test_ipynb_to_pandoc(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_pandoc(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'md:pandoc', 'ipynb_to_pandoc') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_js')) -def test_ipynb_to_js(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_js(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'js', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_js')) -def test_ipynb_to_js_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_js_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'js:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_ts')) -def test_ipynb_to_ts(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_ts(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ts', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_ts')) -def test_ipynb_to_ts_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_ts_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'ts:percent', 'ipynb_to_percent') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_scala')) -def test_ipynb_to_scala(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_scala(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'scala', 'ipynb_to_script') @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_scala')) -def test_ipynb_to_scala_percent(nb_file, header_insert_and_check_version_number_patch): +def test_ipynb_to_scala_percent(nb_file, no_jupytext_version_number): assert_conversion_same_as_mirror(nb_file, 'scala:percent', 'ipynb_to_percent') diff --git a/tests/test_read_simple_markdown.py b/tests/test_read_simple_markdown.py index 95fdd5a41..551805475 100644 --- a/tests/test_read_simple_markdown.py +++ b/tests/test_read_simple_markdown.py @@ -1,7 +1,3 @@ -try: - import unittest.mock as mock -except ImportError: - import mock from nbformat.v4.nbbase import new_code_cell, new_raw_cell, new_markdown_cell from jupytext.compare import compare import jupytext @@ -302,7 +298,7 @@ def test_non_jupyter_code_is_not_split(): assert len(nb.cells) == 1 -def test_read_markdown_idl(text='''--- +def test_read_markdown_idl(no_jupytext_version_number, text='''--- jupyter: kernelspec: display_name: IDL [conda env:gdl] * @@ -321,13 +317,11 @@ def test_read_markdown_idl(text='''--- assert nb.cells[1].cell_type == 'code' assert nb.cells[1].source == 'a = 1' - nb.metadata.pop('jupytext') - with mock.patch('jupytext.header.INSERT_AND_CHECK_VERSION_NUMBER', False): - text2 = jupytext.writes(nb, 'md') + text2 = jupytext.writes(nb, 'md') compare(text, text2) -def test_read_markdown_IDL(text='''--- +def test_read_markdown_IDL(no_jupytext_version_number, text='''--- jupyter: kernelspec: display_name: IDL [conda env:gdl] * @@ -346,7 +340,5 @@ def test_read_markdown_IDL(text='''--- assert nb.cells[1].cell_type == 'code' assert nb.cells[1].source == 'a = 1' - nb.metadata.pop('jupytext') - with mock.patch('jupytext.header.INSERT_AND_CHECK_VERSION_NUMBER', False): - text2 = jupytext.writes(nb, 'md') + text2 = jupytext.writes(nb, 'md') compare(text.replace('```IDL', '```idl'), text2) diff --git a/tests/test_rmd_to_ipynb.py b/tests/test_rmd_to_ipynb.py index 069f18e6f..288b61466 100644 --- a/tests/test_rmd_to_ipynb.py +++ b/tests/test_rmd_to_ipynb.py @@ -7,7 +7,7 @@ @skip_if_dict_is_not_ordered @pytest.mark.parametrize('nb_file', list_notebooks('Rmd')) -def test_identity_write_read(nb_file, header_insert_and_check_version_number_patch): +def test_identity_write_read(nb_file, no_jupytext_version_number): """Test that writing the notebook with ipynb, and read again, yields identity""" with open(nb_file) as fp: diff --git a/tests/test_trust_notebook.py b/tests/test_trust_notebook.py index f23a4fae0..d9ff29cf2 100644 --- a/tests/test_trust_notebook.py +++ b/tests/test_trust_notebook.py @@ -26,7 +26,7 @@ def test_rmd_notebooks_are_trusted(nb_file): @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='hash sign')) -def test_ipynb_notebooks_can_be_trusted(nb_file, tmpdir, header_insert_and_check_version_number_patch): +def test_ipynb_notebooks_can_be_trusted(nb_file, tmpdir, no_jupytext_version_number): cm = TextFileContentsManager() root, file = os.path.split(nb_file) tmp_ipynb = str(tmpdir.join(file)) @@ -72,7 +72,7 @@ def test_ipynb_notebooks_can_be_trusted(nb_file, tmpdir, header_insert_and_check @pytest.mark.parametrize('nb_file', list_notebooks('ipynb_py', skip='hash sign')) def test_ipynb_notebooks_can_be_trusted_even_with_metadata_filter(nb_file, tmpdir, - header_insert_and_check_version_number_patch): + no_jupytext_version_number): cm = TextFileContentsManager() root, file = os.path.split(nb_file) tmp_ipynb = str(tmpdir.join(file))