From 4d6bef1c6cc78111ce1b3560b07965332c0c951c Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Mon, 28 Oct 2019 20:06:15 +0100 Subject: [PATCH] compare actual expected --- jupytext/cli.py | 3 +- jupytext/compare.py | 17 +++++----- tests/test_active_cells.py | 16 ++++----- tests/test_black.py | 14 ++++---- tests/test_cli.py | 2 +- tests/test_compare.py | 4 +-- tests/test_contentsmanager.py | 24 +++++++------- tests/test_escape_magics.py | 4 +-- tests/test_formats.py | 16 ++++----- tests/test_header.py | 4 +-- tests/test_paired_paths.py | 12 +++---- tests/test_pep8.py | 4 +-- tests/test_preserve_empty_cells.py | 2 +- tests/test_read_all_py.py | 2 +- tests/test_read_folding_markers.py | 10 +++--- tests/test_read_simple_R.py | 12 +++---- tests/test_read_simple_bare.py | 2 +- tests/test_read_simple_clojure.py | 2 +- tests/test_read_simple_hydrogen.py | 12 +++---- tests/test_read_simple_ipynb.py | 2 +- tests/test_read_simple_julia.py | 2 +- tests/test_read_simple_markdown.py | 44 ++++++++++++------------- tests/test_read_simple_pandoc.py | 6 ++-- tests/test_read_simple_percent.py | 16 ++++----- tests/test_read_simple_python.py | 52 +++++++++++++++--------------- tests/test_read_simple_rmd.py | 2 +- tests/test_read_simple_scheme.py | 2 +- tests/test_read_simple_sphinx.py | 2 +- tests/test_read_write_functions.py | 4 +-- tests/test_rmd_to_ipynb.py | 2 +- 30 files changed, 148 insertions(+), 148 deletions(-) diff --git a/jupytext/cli.py b/jupytext/cli.py index 19e1a6d85..5d42ffaad 100644 --- a/jupytext/cli.py +++ b/jupytext/cli.py @@ -53,7 +53,6 @@ def parse_jupytext_args(args=None): class RawTextArgumentDefaultsHelpFormatter(argparse.RawTextHelpFormatter, argparse.ArgumentDefaultsHelpFormatter): """Keep the raw formatting in command line help, plus show the default values""" - pass parser = argparse.ArgumentParser( description='Jupyter notebooks as markdown documents, Julia, Python or R scripts', @@ -398,7 +397,7 @@ def jupytext_single_file(nb_file, args, log): notebook = reads(dest_text, fmt=dest_fmt) text = writes(notebook, fmt=fmt) - compare(org_text, text) + compare(text, org_text) except (NotebookDifference, AssertionError) as err: sys.stdout.write('{}: {}'.format(nb_file, str(err))) diff --git a/jupytext/compare.py b/jupytext/compare.py index c1e031cbd..885b3dcf6 100644 --- a/jupytext/compare.py +++ b/jupytext/compare.py @@ -30,11 +30,12 @@ def compare(actual, expected, return_diff=False): diff = '\n'.join(difflib.unified_diff( _multilines(expected), _multilines(actual), - 'first', 'second', lineterm='')) + 'actual', 'expected', lineterm='')) if return_diff: return diff raise AssertionError('\n' + diff) - return '' + if return_diff: + return '' def filtered_cell(cell, preserve_outputs, cell_metadata_filter): @@ -145,7 +146,7 @@ def compare_notebooks(notebook_actual, notebook_expected, fmt=None, allow_expect if ref_cell.metadata != test_cell.metadata: if raise_on_first_difference: try: - compare(ref_cell.metadata, test_cell.metadata) + compare(test_cell.metadata, ref_cell.metadata) except AssertionError as error: raise NotebookDifference("Metadata differ on {} cell #{}: {}\nCell content:\n{}" .format(test_cell.cell_type, i, str(error), ref_cell.source)) @@ -162,7 +163,7 @@ def compare_notebooks(notebook_actual, notebook_expected, fmt=None, allow_expect if ref_lines != test_lines: if raise_on_first_difference: try: - compare('\n'.join(ref_lines), '\n'.join(test_lines)) + compare('\n'.join(test_lines), '\n'.join(ref_lines)) except AssertionError as error: raise NotebookDifference("Cell content differ on {} cell #{}: {}" .format(test_cell.cell_type, i, str(error))) @@ -173,7 +174,7 @@ def compare_notebooks(notebook_actual, notebook_expected, fmt=None, allow_expect if not same_content(ref_cell.source, test_cell.source, allow_removed_final_blank_line): if ref_cell.source != test_cell.source: if raise_on_first_difference: - diff = compare(ref_cell.source, test_cell.source, return_diff=True) + diff = compare(test_cell.source, ref_cell.source, return_diff=True) raise NotebookDifference("Cell content differ on {} cell #{}: {}" .format(test_cell.cell_type, i, diff)) modified_cells.add(i) @@ -192,7 +193,7 @@ def compare_notebooks(notebook_actual, notebook_expected, fmt=None, allow_expect cell_metadata_filter=cell_metadata_filter) try: - compare(ref_cell, test_cell) + compare(test_cell, ref_cell) except AssertionError as error: if raise_on_first_difference: raise NotebookDifference("Cell outputs differ on {} cell #{}: {}" @@ -217,8 +218,8 @@ def compare_notebooks(notebook_actual, notebook_expected, fmt=None, allow_expect # Compare notebook metadata modified_metadata = False try: - compare(filtered_notebook_metadata(notebook_expected), - filtered_notebook_metadata(notebook_actual)) + compare(filtered_notebook_metadata(notebook_actual), + filtered_notebook_metadata(notebook_expected)) except AssertionError as error: if raise_on_first_difference: raise NotebookDifference("Notebook metadata differ: {}".format(str(error))) diff --git a/tests/test_active_cells.py b/tests/test_active_cells.py index a63ce7d88..5f24fd0d5 100644 --- a/tests/test_active_cells.py +++ b/tests/test_active_cells.py @@ -57,7 +57,7 @@ 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)) + compare(jupytext.writes(nb, ext), ACTIVE_ALL[ext]) compare(nb.cells[0], ACTIVE_ALL['.ipynb']) @@ -92,7 +92,7 @@ def test_active_all(ext, no_jupytext_version_number): 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)) + compare(jupytext.writes(nb, ext), ACTIVE_IPYNB[ext]) compare(nb.cells[0], ACTIVE_IPYNB['.ipynb']) @@ -127,7 +127,7 @@ def test_active_ipynb(ext, no_jupytext_version_number): 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)) + compare(jupytext.writes(nb, ext), ACTIVE_IPYNB_RMD_USING_TAG[ext]) compare(nb.cells[0], ACTIVE_IPYNB_RMD_USING_TAG['.ipynb']) @@ -147,7 +147,7 @@ def test_active_ipynb_rmd_using_tags(ext, no_jupytext_version_number): 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')) + compare(jupytext.writes(nb, 'R:spin'), ACTIVE_IPYNB_RSPIN['.R']) compare(nb.cells[0], ACTIVE_IPYNB_RSPIN['.ipynb']) @@ -178,7 +178,7 @@ def test_active_ipynb_rspin(no_jupytext_version_number): 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)) + compare(jupytext.writes(nb, ext), ACTIVE_PY_IPYNB[ext]) compare(nb.cells[0], ACTIVE_PY_IPYNB['.ipynb']) @@ -205,7 +205,7 @@ def test_active_py_ipynb(ext, no_jupytext_version_number): 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)) + compare(jupytext.writes(nb, ext), ACTIVE_PY_R_IPYNB[ext]) compare(nb.cells[0], ACTIVE_PY_R_IPYNB['.ipynb']) @@ -229,7 +229,7 @@ def test_active_py_r_ipynb(ext, no_jupytext_version_number): 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)) + compare(jupytext.writes(nb, ext), ACTIVE_RMD[ext]) compare(nb.cells[0], ACTIVE_RMD['.ipynb']) @@ -254,5 +254,5 @@ def test_active_rmd(ext, no_jupytext_version_number): 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)) + compare(jupytext.writes(nb, ext), ACTIVE_NOT_INCLUDE_RMD[ext]) compare(nb.cells[0], ACTIVE_NOT_INCLUDE_RMD['.ipynb']) diff --git a/tests/test_black.py b/tests/test_black.py index edacd863a..5bef4c5c7 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -59,7 +59,7 @@ def test_pipe_into_black(): nb_dest = new_notebook(cells=[new_code_cell('1 + 1')]) nb_pipe = pipe_notebook(nb_org, 'black') - compare(nb_dest, nb_pipe) + compare(nb_pipe, nb_dest) @requires_autopep8 @@ -68,7 +68,7 @@ def test_pipe_into_autopep8(): nb_dest = new_notebook(cells=[new_code_cell('1 + 1')]) nb_pipe = pipe_notebook(nb_org, 'autopep8 -') - compare(nb_dest, nb_pipe) + compare(nb_pipe, nb_dest) @requires_flake8 @@ -102,7 +102,7 @@ def test_apply_black_through_jupytext(tmpdir, nb_file): write(nb_org, tmp_ipynb) jupytext([tmp_ipynb, '--pipe', 'black']) nb_now = read(tmp_ipynb) - compare(nb_black, nb_now) + compare(nb_now, nb_black) # Write to another folder using dots script_fmt = os.path.join('..', 'script_folder//py:percent') @@ -111,7 +111,7 @@ def test_apply_black_through_jupytext(tmpdir, nb_file): assert os.path.isfile(tmp_py) nb_now = read(tmp_py) nb_now.metadata = metadata - compare(nb_black, nb_now) + compare(nb_now, nb_black) os.remove(tmp_py) # Map to another folder based on file name @@ -121,7 +121,7 @@ def test_apply_black_through_jupytext(tmpdir, nb_file): assert os.path.isfile(tmp_py) nb_now = read(tmp_py) nb_now.metadata = metadata - compare(nb_black, nb_now) + compare(nb_now, nb_black) @requires_black @@ -143,14 +143,14 @@ def test_apply_black_and_sync_on_paired_notebook(tmpdir, nb_file): jupytext([tmp_ipynb, '--pipe', 'black', '--sync']) nb_now = read(tmp_ipynb) - compare(nb_black, nb_now) + compare(nb_now, nb_black) assert 'language_info' in nb_now.metadata nb_now = read(tmp_py) nb_now.metadata['jupytext'].pop('text_representation') nb_black.metadata = {key: nb_black.metadata[key] for key in nb_black.metadata if key in _DEFAULT_NOTEBOOK_METADATA} - compare(nb_black, nb_now) + compare(nb_now, nb_black) @requires_black diff --git a/tests/test_cli.py b/tests/test_cli.py index 6ecb64a4e..c2052b47b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -919,7 +919,7 @@ def test_convert_and_update_preserves_notebook(nb_file, fmt, tmpdir): nb_org = read(nb_file) nb_now = read(tmp_ipynb) - compare(nb_org, nb_now) + compare(nb_now, nb_org) def test_incorrect_notebook_causes_early_exit(tmpdir): diff --git a/tests/test_compare.py b/tests/test_compare.py index d03a39472..cf300876f 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -64,8 +64,8 @@ def test_compare_on_notebooks(notebook_actual, notebook_expected): compare(notebook_actual, notebook_expected) assert str(err.value) == """ ---- first -+++ second +--- actual ++++ expected @@ -15,7 +15,7 @@ { "cell_type": "markdown", diff --git a/tests/test_contentsmanager.py b/tests/test_contentsmanager.py index 11b4e8e1e..388904499 100644 --- a/tests/test_contentsmanager.py +++ b/tests/test_contentsmanager.py @@ -206,7 +206,7 @@ def test_pair_plain_script(py_file, tmpdir): with open(str(tmpdir.join(tmp_py))) as fp: script2 = fp.read() - compare(script, script2) + compare(script2, script) # reopen py file with the cm nb2 = cm.get(tmp_py)['content'] @@ -278,7 +278,7 @@ def test_load_save_py_freeze_metadata(script, tmpdir): with open(str(tmpdir.join(tmp_nbpy))) as fp: text_py2 = fp.read() - compare(text_py, text_py2) + compare(text_py2, text_py) @skip_if_dict_is_not_ordered @@ -487,7 +487,7 @@ def test_load_save_percent_format(nb_file, tmpdir): # Remove the YAML header text_py2 = text_py2[-len(text_py):] - compare(text_py, text_py2) + compare(text_py2, text_py) @skip_if_dict_is_not_ordered @@ -1011,7 +1011,7 @@ def test_no_metadata_added_to_scripts_139(tmpdir): cm.save(model=model, path='script.py') with open(tmp_script) as fp: - compare(text, fp.read()) + compare(fp.read(), text) @pytest.mark.parametrize('nb_file,ext', itertools.product(list_notebooks('ipynb_py'), ['.py', '.ipynb'])) @@ -1087,7 +1087,7 @@ def test_python_kernel_preserves_R_files(nb_file, tmpdir): with open(tmp_r_file) as fp: script2 = fp.read() - compare(script, script2) + compare(script2, script) def test_pair_notebook_in_another_folder(tmpdir): @@ -1174,7 +1174,7 @@ def test_split_at_heading_option(tmpdir): nb.metadata['jupytext']['notebook_metadata_filter'] = '-all' text2 = writes(nb, 'md') - compare(text, text2) + compare(text2, text) def test_load_then_change_formats(tmpdir): @@ -1343,7 +1343,7 @@ def test_vim_folding_markers(tmpdir): # Remove YAML header text = re.sub(re.compile(r'# ---.*# ---\n\n', re.DOTALL), '', text) - compare("""# region + compare(text, """# region '''Sample cell with region markers''' '''End of the cell''' # end region @@ -1354,7 +1354,7 @@ def test_vim_folding_markers(tmpdir): b = 1 # }}} -""", text) +""") def test_vscode_pycharm_folding_markers(tmpdir): @@ -1390,7 +1390,7 @@ def test_vscode_pycharm_folding_markers(tmpdir): # Remove YAML header text = re.sub(re.compile(r'# ---.*# ---\n\n', re.DOTALL), '', text) - compare("""# {{{ + compare(text, """# {{{ '''Sample cell with region markers''' '''End of the cell''' # }}} @@ -1401,7 +1401,7 @@ def test_vscode_pycharm_folding_markers(tmpdir): b = 1 # endregion -""", text) +""") def test_open_file_with_default_cell_markers(tmpdir): @@ -1439,7 +1439,7 @@ def test_open_file_with_default_cell_markers(tmpdir): # endregion """ - compare(expected, text2) + compare(text2, expected) def test_save_file_with_default_cell_markers(tmpdir): @@ -1471,7 +1471,7 @@ def test_save_file_with_default_cell_markers(tmpdir): with open(tmp_py) as fp: text2 = fp.read() - compare('\n'.join(text.splitlines()), '\n'.join(text2.splitlines()[-len(text.splitlines()):])) + compare('\n'.join(text2.splitlines()[-len(text.splitlines()):]), '\n'.join(text.splitlines())) nb2 = cm.get('nb.py')['content'] compare_notebooks(nb2, nb) diff --git a/tests/test_escape_magics.py b/tests/test_escape_magics.py index daec4de17..7d5a4e1f0 100644 --- a/tests/test_escape_magics.py +++ b/tests/test_escape_magics.py @@ -142,12 +142,12 @@ def g(x): return x+1""")]) text = jupytext.writes(nb, 'py') - compare("""# + + compare(text, """# + # %load_ext watermark # %watermark -u -n -t -z \\ # -p jupytext -v def g(x): return x+1 -""", text) +""") compare_notebooks(jupytext.reads(text, 'py'), nb) diff --git a/tests/test_formats.py b/tests/test_formats.py index aa343270e..c66db32b2 100644 --- a/tests/test_formats.py +++ b/tests/test_formats.py @@ -152,31 +152,31 @@ def test_compress_formats(): def test_rearrange_jupytext_metadata(): metadata = {'nbrmd_formats': 'ipynb,py'} rearrange_jupytext_metadata(metadata) - compare({'jupytext': {'formats': 'ipynb,py'}}, metadata) + compare(metadata, {'jupytext': {'formats': 'ipynb,py'}}) metadata = {'jupytext_formats': 'ipynb,py'} rearrange_jupytext_metadata(metadata) - compare({'jupytext': {'formats': 'ipynb,py'}}, metadata) + compare(metadata, {'jupytext': {'formats': 'ipynb,py'}}) metadata = {'executable': '#!/bin/bash'} rearrange_jupytext_metadata(metadata) - compare({'jupytext': {'executable': '#!/bin/bash'}}, metadata) + compare(metadata, {'jupytext': {'executable': '#!/bin/bash'}}) def test_rearrange_jupytext_metadata_metadata_filter(): metadata = {'jupytext': {'metadata_filter': {'notebook': {'additional': ['one', 'two'], 'excluded': 'all'}, 'cells': {'additional': 'all', 'excluded': ['three', 'four']}}}} rearrange_jupytext_metadata(metadata) - compare({'jupytext': {'notebook_metadata_filter': 'one,two,-all', - 'cell_metadata_filter': 'all,-three,-four'}}, metadata) + compare(metadata, {'jupytext': {'notebook_metadata_filter': 'one,two,-all', + 'cell_metadata_filter': 'all,-three,-four'}}) def test_rearrange_jupytext_metadata_add_dot_in_suffix(): metadata = {'jupytext': {'text_representation': {'jupytext_version': '0.8.6'}, 'formats': 'ipynb,pct.py,lgt.py'}} rearrange_jupytext_metadata(metadata) - compare({'jupytext': {'text_representation': {'jupytext_version': '0.8.6'}, - 'formats': 'ipynb,.pct.py,.lgt.py'}}, metadata) + compare(metadata, {'jupytext': {'text_representation': {'jupytext_version': '0.8.6'}, + 'formats': 'ipynb,.pct.py,.lgt.py'}}) def test_fix_139(): @@ -229,4 +229,4 @@ def test_pandoc_format_is_preserved(): long = long_form_multiple_formats(formats_org) formats_new = short_form_multiple_formats(long) - compare(formats_org, formats_new) + compare(formats_new, formats_org) diff --git a/tests/test_header.py b/tests/test_header.py index a329672af..762456d13 100644 --- a/tests/test_header.py +++ b/tests/test_header.py @@ -96,6 +96,6 @@ def test_notebook_from_plain_script_has_metadata_filter(script="""print('Hello w nb = jupytext.reads(script, '.py') assert nb.metadata.get('jupytext', {}).get('notebook_metadata_filter') == '-all' assert nb.metadata.get('jupytext', {}).get('cell_metadata_filter') == '-all' - scripts2 = jupytext.writes(nb, '.py') + script2 = jupytext.writes(nb, '.py') - compare(script, scripts2) + compare(script2, script) diff --git a/tests/test_paired_paths.py b/tests/test_paired_paths.py index 069dda42e..57b4ba6d9 100644 --- a/tests/test_paired_paths.py +++ b/tests/test_paired_paths.py @@ -8,8 +8,8 @@ def test_simple_pair(): formats = long_form_multiple_formats('ipynb,py') expected_paths = ['notebook.ipynb', 'notebook.py'] - compare(list(zip(expected_paths, formats)), paired_paths('notebook.ipynb', 'ipynb', formats)) - compare(list(zip(expected_paths, formats)), paired_paths('notebook.py', 'py', formats)) + compare(paired_paths('notebook.ipynb', 'ipynb', formats), list(zip(expected_paths, formats))) + compare(paired_paths('notebook.py', 'py', formats), list(zip(expected_paths, formats))) def test_base_path(): @@ -23,7 +23,7 @@ def test_many_and_suffix(): formats = long_form_multiple_formats('ipynb,.pct.py,_lgt.py') expected_paths = ['notebook.ipynb', 'notebook.pct.py', 'notebook_lgt.py'] for fmt, path in zip(formats, expected_paths): - compare(list(zip(expected_paths, formats)), paired_paths(path, fmt, formats)) + compare(paired_paths(path, fmt, formats), list(zip(expected_paths, formats))) with pytest.raises(InconsistentPath): paired_paths('wrong_suffix.py', 'py', formats) @@ -41,12 +41,12 @@ def test_prefix_and_suffix(): 'parent/script_folder/NOTEBOOK_NAME_in_percent_format.py', 'parent/script_folder/NOTEBOOK_NAME_in_light_format.py'] for fmt, path in zip(formats, expected_paths): - compare(list(zip(expected_paths, formats)), paired_paths(path, fmt, formats)) + compare(paired_paths(path, fmt, formats), list(zip(expected_paths, formats))) # without the parent folder expected_paths = [path[7:] for path in expected_paths] for fmt, path in zip(formats, expected_paths): - compare(list(zip(expected_paths, formats)), paired_paths(path, fmt, formats)) + compare(paired_paths(path, fmt, formats), list(zip(expected_paths, formats))) # Not the expected parent folder with pytest.raises(InconsistentPath): @@ -69,7 +69,7 @@ def test_prefix_on_root_174(): expected_paths = ['/Untitled.ipynb', '/python/Untitled.py'] for fmt, path in zip(formats, expected_paths): - compare(list(zip(expected_paths, formats)), paired_paths(path, fmt, formats)) + compare(paired_paths(path, fmt, formats), list(zip(expected_paths, formats))) def test_duplicated_paths(): diff --git a/tests/test_pep8.py b/tests/test_pep8.py index 6e66ff316..9beba822c 100644 --- a/tests/test_pep8.py +++ b/tests/test_pep8.py @@ -131,7 +131,7 @@ def g(x): assert not cell.metadata text2 = writes(nb, 'py') - compare(text, text2) + compare(text2, text) def test_pep8_bis(): @@ -150,7 +150,7 @@ def f(x): assert not cell.metadata text2 = writes(nb, 'py') - compare(text, text2) + compare(text2, text) @pytest.mark.parametrize('py_file', [py_file for py_file in list_notebooks('../jupytext') + list_notebooks('.') if diff --git a/tests/test_preserve_empty_cells.py b/tests/test_preserve_empty_cells.py index 627db42ca..844340520 100644 --- a/tests/test_preserve_empty_cells.py +++ b/tests/test_preserve_empty_cells.py @@ -13,7 +13,7 @@ def test_file_with_blank_lines(blank_lines): notebook = jupytext.reads(py_script, 'py') py_script2 = jupytext.writes(notebook, 'py') - compare(py_script, py_script2) + compare(py_script2, py_script) @pytest.mark.parametrize('blank_cells', range(1, 3)) diff --git a/tests/test_read_all_py.py b/tests/test_read_all_py.py index f229261a0..69ca7f0c0 100644 --- a/tests/test_read_all_py.py +++ b/tests/test_read_all_py.py @@ -16,4 +16,4 @@ def test_identity_source_write_read(py_file): nb = jupytext.reads(py, 'py') py2 = jupytext.writes(nb, 'py') - compare(py, py2) + compare(py2, py) diff --git a/tests/test_read_folding_markers.py b/tests/test_read_folding_markers.py index e236063f7..83212d2ec 100644 --- a/tests/test_read_folding_markers.py +++ b/tests/test_read_folding_markers.py @@ -25,7 +25,7 @@ def test_mark_cell_with_vim_folding_markers( assert nb.cells[1].metadata == {'title': 'And this is a foldable code region with metadata', 'key': 'value'} script2 = jupytext.writes(nb, 'py') - compare(script, script2) + compare(script2, script) # endregion @@ -51,7 +51,7 @@ def test_mark_cell_with_vscode_pycharm_folding_markers( assert nb.cells[1].metadata == {'title': 'And this is a foldable code region with metadata', 'key': 'value'} script2 = jupytext.writes(nb, 'py') - compare(script, script2) + compare(script2, script) def test_mark_cell_with_no_title_and_inner_region( @@ -90,7 +90,7 @@ def f(x): assert len(nb.cells) == 6 script2 = jupytext.writes(nb, 'py') - compare(script, script2) + compare(script2, script) # endregion @@ -115,7 +115,7 @@ def test_adjacent_regions( assert nb.cells[2].source == '# endregion' script2 = jupytext.writes(nb, 'py') - compare(script, script2) + compare(script2, script) def test_indented_markers_are_ignored( @@ -132,4 +132,4 @@ def test_indented_markers_are_ignored( assert nb.cells[0].cell_type == 'code' script2 = jupytext.writes(nb, 'py') - compare(script, script2) + compare(script2, script) diff --git a/tests/test_read_simple_R.py b/tests/test_read_simple_R.py index be184f313..035ce60bd 100644 --- a/tests/test_read_simple_R.py +++ b/tests/test_read_simple_R.py @@ -37,7 +37,7 @@ def test_read_simple_file(ext, rnb="""#' --- y + 1''') rnb2 = jupytext.writes(nb, ext) - compare(rnb, rnb2) + compare(rnb2, rnb) @pytest.mark.parametrize('ext', ['.r', '.R']) @@ -81,7 +81,7 @@ def test_read_less_simple_file(ext, rnb="""#' --- }''') rnb2 = jupytext.writes(nb, ext) - compare(rnb, rnb2) + compare(rnb2, rnb) @pytest.mark.parametrize('ext', ['.r', '.R']) @@ -109,7 +109,7 @@ def test_no_space_after_code(ext, rnb=u"""# -*- coding: utf-8 -*- assert nb.cells[2].source == u'And a new cell, and non ascii contĂȘnt' rnb2 = jupytext.writes(nb, ext) - compare(rnb, rnb2) + compare(rnb2, rnb) @pytest.mark.parametrize('ext', ['.r', '.R']) @@ -119,7 +119,7 @@ def test_read_write_script(ext, rnb="""#!/usr/bin/env Rscript """): nb = jupytext.reads(rnb, ext) rnb2 = jupytext.writes(nb, ext) - compare(rnb, rnb2) + compare(rnb2, rnb) @pytest.mark.parametrize('ext', ['.r', '.R']) @@ -145,7 +145,7 @@ def test_escape_start_pattern(ext, rnb="""#' The code start pattern '#+' can #+ cell_name language="python" 1 + 1''') rnb2 = jupytext.writes(nb, ext) - compare(rnb, rnb2) + compare(rnb2, rnb) @pytest.mark.parametrize('ext', ['.r', '.R']) @@ -167,4 +167,4 @@ def test_read_simple_r(ext, text="""# This is a very simple R file assert nb.cells[1].source == 'cars' assert nb.cells[2].source == 'plot(cars)' text2 = jupytext.writes(nb, ext) - compare(text, text2) + compare(text2, text) diff --git a/tests/test_read_simple_bare.py b/tests/test_read_simple_bare.py index 4833228c1..a01b02e4f 100644 --- a/tests/test_read_simple_bare.py +++ b/tests/test_read_simple_bare.py @@ -28,4 +28,4 @@ def h(x): assert len(nb2.cells) == 7 nb1.cells = nb1.cells[:5] nb2.cells = nb2.cells[:5] - compare(nb1, nb2) + compare(nb2, nb1) diff --git a/tests/test_read_simple_clojure.py b/tests/test_read_simple_clojure.py index eed7d2b96..5033e6644 100644 --- a/tests/test_read_simple_clojure.py +++ b/tests/test_read_simple_clojure.py @@ -28,4 +28,4 @@ def test_read_simple_file(script=""";; --- (println "Hello World")))""") script2 = jupytext.writes(nb, 'clj') - compare(script, script2) + compare(script2, script) diff --git a/tests/test_read_simple_hydrogen.py b/tests/test_read_simple_hydrogen.py index 8d9f874da..a94651856 100644 --- a/tests/test_read_simple_hydrogen.py +++ b/tests/test_read_simple_hydrogen.py @@ -52,7 +52,7 @@ def test_read_simple_file(script="""# --- assert nb.cells[5].metadata == {'title': 'And now a code cell'} script2 = jupytext.writes(nb, 'py:hydrogen') - compare(script, script2) + compare(script2, script) def test_read_cell_with_metadata( @@ -68,7 +68,7 @@ def test_read_cell_with_metadata( 'tags': ['parameters']} script2 = jupytext.writes(nb, 'py:hydrogen') - compare(script, script2) + compare(script2, script) def test_read_nbconvert_script(script=""" @@ -142,7 +142,7 @@ def f(x): assert not nb.cells[i].source.endswith('\n') script2 = jupytext.writes(nb, 'py:hydrogen') - compare(script, script2) + compare(script2, script) def test_no_crash_on_square_bracket(script="""# %% In [2] @@ -150,7 +150,7 @@ def test_no_crash_on_square_bracket(script="""# %% In [2] """): nb = jupytext.reads(script, 'py') script2 = jupytext.writes(nb, 'py:hydrogen') - compare(script, script2) + compare(script2, script) def test_nbconvert_cell(script="""# In[2]: @@ -161,7 +161,7 @@ def test_nbconvert_cell(script="""# In[2]: expected = """# %% print('Hello') """ - compare(expected, script2) + compare(script2, expected) def test_nbformat_v3_nbpy_cell(script="""# @@ -172,4 +172,4 @@ def test_nbformat_v3_nbpy_cell(script="""# expected = """# %% print('Hello') """ - compare(expected, script2) + compare(script2, expected) diff --git a/tests/test_read_simple_ipynb.py b/tests/test_read_simple_ipynb.py index 0250af851..9f7aa1cce 100644 --- a/tests/test_read_simple_ipynb.py +++ b/tests/test_read_simple_ipynb.py @@ -19,4 +19,4 @@ def test_save_ipynb_with_jupytext_has_final_newline(tmpdir): with open(file_nbformat) as fp: text_nbformat = fp.read() - compare(text_nbformat, text_jupytext) + compare(text_jupytext, text_nbformat) diff --git a/tests/test_read_simple_julia.py b/tests/test_read_simple_julia.py index 7ef3e7e91..ecf1d7d51 100644 --- a/tests/test_read_simple_julia.py +++ b/tests/test_read_simple_julia.py @@ -45,4 +45,4 @@ def test_read_simple_file(julia='''""" compare(nb.cells[2].source, 'And a markdown comment') julia2 = jupytext.writes(nb, 'jl') - compare(julia, julia2) + compare(julia2, julia) diff --git a/tests/test_read_simple_markdown.py b/tests/test_read_simple_markdown.py index 0190add48..7a074b8ce 100644 --- a/tests/test_read_simple_markdown.py +++ b/tests/test_read_simple_markdown.py @@ -95,7 +95,7 @@ def test_read_mostly_py_markdown_file(markdown="""--- 'outputs': []}]) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_read_md_and_markdown_regions(markdown="""Some text @@ -131,7 +131,7 @@ def test_read_md_and_markdown_regions(markdown="""Some text cell""", metadata={'region_name': 'markdown'})]) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_read_mostly_R_markdown_file(markdown="""```R @@ -156,7 +156,7 @@ def test_read_mostly_R_markdown_file(markdown="""```R 'outputs': []}]) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_read_markdown_file_no_language(markdown="""``` @@ -169,7 +169,7 @@ def test_read_markdown_file_no_language(markdown="""``` """): nb = jupytext.reads(markdown, 'md') markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_read_julia_notebook(markdown="""```julia @@ -181,7 +181,7 @@ def test_read_julia_notebook(markdown="""```julia assert len(nb.cells) == 1 assert nb.cells[0].cell_type == 'code' markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_split_on_header(markdown="""A paragraph @@ -199,7 +199,7 @@ def test_split_on_header(markdown="""A paragraph assert nb.cells[2].source == '## H2 Header\n\nAnother paragraph' assert len(nb.cells) == 3 markdown2 = jupytext.writes(nb, fmt) - compare(markdown, markdown2) + compare(markdown2, markdown) def test_split_on_header_after_two_blank_lines(markdown="""A paragraph @@ -210,7 +210,7 @@ def test_split_on_header_after_two_blank_lines(markdown="""A paragraph fmt = {'extension': '.Rmd', 'split_at_heading': True} nb = jupytext.reads(markdown, fmt) markdown2 = jupytext.writes(nb, fmt) - compare(markdown, markdown2) + compare(markdown2, markdown) def test_code_cell_with_metadata(markdown="""```python tags=["parameters"] @@ -221,7 +221,7 @@ def test_code_cell_with_metadata(markdown="""```python tags=["parameters"] nb = jupytext.reads(markdown, 'md') compare(nb.cells[0], new_code_cell(source='a = 1\nb = 2', metadata={'tags': ['parameters']})) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_raw_cell_with_metadata_json(markdown=""" @@ -231,7 +231,7 @@ def test_raw_cell_with_metadata_json(markdown=""" nb = jupytext.reads(markdown, 'md') compare(nb.cells[0], new_raw_cell(source='raw content', metadata={'key': 'value'})) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_raw_cell_with_metadata(markdown=""" @@ -241,7 +241,7 @@ def test_raw_cell_with_metadata(markdown=""" nb = jupytext.reads(markdown, 'md') compare(nb.cells[0], new_raw_cell(source='raw content', metadata={'key': 'value'})) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_read_raw_cell_markdown_version_1_1(markdown="""--- @@ -311,7 +311,7 @@ def test_markdown_cell_with_metadata_json(markdown=""" @@ -325,7 +325,7 @@ def test_markdown_cell_with_metadata(markdown=""" compare(nb.cells[0], new_markdown_cell(source='A long\n\n\nmarkdown cell', metadata={'key': 'value'})) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_two_markdown_cells(markdown="""# A header @@ -341,7 +341,7 @@ def test_two_markdown_cells(markdown="""# A header compare(nb.cells[0], new_markdown_cell(source='# A header')) compare(nb.cells[1], new_markdown_cell(source='A long\n\n\nmarkdown cell')) markdown2 = jupytext.writes(nb, 'md') - compare(markdown, markdown2) + compare(markdown2, markdown) def test_combine_md_version_one(): @@ -397,17 +397,17 @@ def test_jupyter_cell_is_not_split(): """ nb = jupytext.reads(text, 'md') assert nb.cells[0].cell_type == 'markdown' - compare("""Here we have a markdown -file with a jupyter code cell""", nb.cells[0].source) + compare(nb.cells[0].source, """Here we have a markdown +file with a jupyter code cell""") assert nb.cells[1].cell_type == 'code' - compare("""1 + 1 + compare(nb.cells[1].source, """1 + 1 -2 + 2""", nb.cells[1].source) +2 + 2""") assert nb.cells[2].cell_type == 'markdown' - compare("the code cell should become a Jupyter cell.", nb.cells[2].source) + compare(nb.cells[2].source, "the code cell should become a Jupyter cell.") assert len(nb.cells) == 3 @@ -423,7 +423,7 @@ def test_indented_code_is_not_split(): the code cell should not become a Jupyter cell, nor be split into two pieces.""" nb = jupytext.reads(text, 'md') - compare(text, nb.cells[0].source) + compare(nb.cells[0].source, text) assert nb.cells[0].cell_type == 'markdown' assert len(nb.cells) == 1 @@ -442,7 +442,7 @@ def test_non_jupyter_code_is_not_split(): the code cell should not become a Jupyter cell, nor be split into two pieces.""" nb = jupytext.reads(text, 'md') - compare(text, nb.cells[0].source) + compare(nb.cells[0].source, text) assert nb.cells[0].cell_type == 'markdown' assert len(nb.cells) == 1 @@ -467,7 +467,7 @@ def test_read_markdown_idl(no_jupytext_version_number, text='''--- assert nb.cells[1].source == 'a = 1' text2 = jupytext.writes(nb, 'md') - compare(text, text2) + compare(text2, text) def test_read_markdown_IDL(no_jupytext_version_number, text='''--- @@ -490,7 +490,7 @@ def test_read_markdown_IDL(no_jupytext_version_number, text='''--- assert nb.cells[1].source == 'a = 1' text2 = jupytext.writes(nb, 'md') - compare(text.replace('```IDL', '```idl'), text2) + compare(text2, text.replace('```IDL', '```idl')) def test_inactive_cell(text='''```python active="md" diff --git a/tests/test_read_simple_pandoc.py b/tests/test_read_simple_pandoc.py index e2514224b..32b076739 100644 --- a/tests/test_read_simple_pandoc.py +++ b/tests/test_read_simple_pandoc.py @@ -23,7 +23,7 @@ def test_pandoc_implicit(markdown='''# Lorem ipsum compare_notebooks(nb2, nb) markdown3 = jupytext.writes(nb2, 'md') - compare(markdown2, markdown3) + compare(markdown3, markdown2) @requires_pandoc @@ -36,7 +36,7 @@ def test_pandoc_explicit(markdown='''::: {.cell .markdown} nb = jupytext.reads(markdown, 'md') markdown2 = jupytext.writes(nb, 'md') - compare(markdown, '\n'.join(markdown2.splitlines()[12:])) + compare('\n'.join(markdown2.splitlines()[12:]), markdown) @requires_pandoc @@ -48,7 +48,7 @@ def test_pandoc_utf8_in_md(markdown='''::: {.cell .markdown} nb = jupytext.reads(markdown, 'md') markdown2 = jupytext.writes(nb, 'md') - compare(markdown, '\n'.join(markdown2.splitlines()[12:])) + compare('\n'.join(markdown2.splitlines()[12:]), markdown) @requires_pandoc diff --git a/tests/test_read_simple_percent.py b/tests/test_read_simple_percent.py index ffb766a15..642d3a849 100644 --- a/tests/test_read_simple_percent.py +++ b/tests/test_read_simple_percent.py @@ -49,7 +49,7 @@ def test_read_simple_file(script="""# --- 7''', metadata={'title': 'And now a code cell'})]), nb) script2 = jupytext.writes(nb, 'py:percent') - compare(script, script2) + compare(script2, script) def test_read_cell_with_metadata( @@ -65,7 +65,7 @@ def test_read_cell_with_metadata( 'tags': ['parameters']} script2 = jupytext.writes(nb, 'py:percent') - compare(script, script2) + compare(script2, script) def test_read_nbconvert_script(script=""" @@ -138,7 +138,7 @@ def f(x): assert not nb.cells[i].source.endswith('\n') script2 = jupytext.writes(nb, 'py:percent') - compare(script, script2) + compare(script2, script) def test_no_crash_on_square_bracket(script="""# %% In [2] @@ -146,7 +146,7 @@ def test_no_crash_on_square_bracket(script="""# %% In [2] """): nb = jupytext.reads(script, 'py') script2 = jupytext.writes(nb, 'py:percent') - compare(script, script2) + compare(script2, script) def test_nbconvert_cell(script="""# In[2]: @@ -157,7 +157,7 @@ def test_nbconvert_cell(script="""# In[2]: expected = """# %% print('Hello') """ - compare(expected, script2) + compare(script2, expected) def test_nbformat_v3_nbpy_cell(script="""# @@ -168,7 +168,7 @@ def test_nbformat_v3_nbpy_cell(script="""# expected = """# %% print('Hello') """ - compare(expected, script2) + compare(script2, expected) def test_multiple_empty_cells(): @@ -181,10 +181,10 @@ def test_multiple_empty_cells(): # %% """ - compare(expected, text) + compare(text, expected) nb2 = jupytext.reads(text, 'py:percent') nb2.metadata = nb.metadata - compare(nb, nb2) + compare(nb2, nb) def test_first_cell_markdown_191(): diff --git a/tests/test_read_simple_python.py b/tests/test_read_simple_python.py index 6e7c3d0df..87934af20 100644 --- a/tests/test_read_simple_python.py +++ b/tests/test_read_simple_python.py @@ -36,7 +36,7 @@ def h(y): return y-1''') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_less_simple_file(pynb="""# --- @@ -73,7 +73,7 @@ def h(y): '''# And a comment on h\ndef h(y):\n return y-1''') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_non_pep8_file(pynb="""# --- @@ -104,7 +104,7 @@ def f(x): ' return x+1') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_cell_two_blank_lines(pynb="""# --- @@ -127,7 +127,7 @@ def test_read_cell_two_blank_lines(pynb="""# --- assert nb.cells[1].source == 'a = 1\n\n\na + 2' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_cell_explicit_start(pynb=''' @@ -141,7 +141,7 @@ def data(): '''): nb = jupytext.reads(pynb, 'py') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_complex_cells(pynb='''import pandas as pd @@ -192,7 +192,7 @@ def data2(): # -''') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_prev_function( @@ -207,11 +207,11 @@ def data(): '''): nb = jupytext.reads(pynb, 'py') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) """): nb = jupytext.reads(pynb, 'py') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_cell_with_one_blank_line_end(pynb="""import pandas @@ -220,7 +220,7 @@ def test_read_cell_with_one_blank_line_end(pynb="""import pandas nb = jupytext.reads(pynb, 'py') assert len(nb.cells) == 1 pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_code_cell_fully_commented(pynb="""# + @@ -233,7 +233,7 @@ def test_read_code_cell_fully_commented(pynb="""# + assert nb.cells[0].source == """# This is a code cell that # only contains comments""" pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_file_with_two_blank_line_end(pynb="""import pandas @@ -242,7 +242,7 @@ def test_file_with_two_blank_line_end(pynb="""import pandas """): nb = jupytext.reads(pynb, 'py') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_one_blank_lines_after_endofcell(pynb="""# + @@ -267,7 +267,7 @@ def test_one_blank_lines_after_endofcell(pynb="""# + assert nb.cells[1].source == '''# This cell is a cell with implicit start 1 + 1''' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_two_cells_with_explicit_start(pynb="""# + @@ -295,7 +295,7 @@ def test_two_cells_with_explicit_start(pynb="""# + 2 + 2''' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_escape_start_pattern(pynb="""# The code start pattern '# +' can @@ -320,7 +320,7 @@ def test_escape_start_pattern(pynb="""# The code start pattern '# +' can # + {"sample_metadata": "value"} 1 + 1''') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_dictionary_with_blank_lines_not_broken( @@ -349,7 +349,7 @@ def test_dictionary_with_blank_lines_not_broken( # and the end 'z': 'Z'}''' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_isolated_cell_with_magic(pynb="""# --- @@ -386,7 +386,7 @@ def test_isolated_cell_with_magic(pynb="""# --- assert nb.cells[5].source == '%matplotlib inline\n1 + 1' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_multiline_comment(pynb="""'''This is a multiline @@ -415,7 +415,7 @@ def test_read_multiline_comment(pynb="""'''This is a multiline assert nb.cells[1].source == '1 + 1' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_no_space_after_code(pynb=u"""# -*- coding: utf-8 -*- @@ -437,7 +437,7 @@ def f(x): assert nb.cells[2].source == u'And a new cell, and non ascii contĂȘnt' pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_write_script(pynb="""#!/usr/bin/env python @@ -446,7 +446,7 @@ def test_read_write_script(pynb="""#!/usr/bin/env python """): nb = jupytext.reads(pynb, 'py') pynb2 = jupytext.writes(nb, 'py') - compare(pynb, pynb2) + compare(pynb2, pynb) def test_read_write_script_with_metadata_241(pynb="""#!/usr/bin/env python3 @@ -478,7 +478,7 @@ def test_read_write_script_with_metadata_241(pynb="""#!/usr/bin/env python3 def remove_version_info(text): return '\n'.join([line for line in text.splitlines() if 'version' not in line]) - compare(remove_version_info(pynb), remove_version_info(pynb2)) + compare(remove_version_info(pynb2), remove_version_info(pynb)) def test_notebook_blank_lines(script="""# + @@ -527,7 +527,7 @@ def h(x): script2 = jupytext.writes(notebook, 'py') - compare(script, script2) + compare(script2, script) def test_notebook_two_blank_lines_before_next_cell(script="""# + @@ -561,7 +561,7 @@ def g(x): script2 = jupytext.writes(notebook, 'py') - compare(script, script2) + compare(script2, script) def test_notebook_one_blank_line_between_cells(script="""# + @@ -614,7 +614,7 @@ def j(x): script2 = jupytext.writes(notebook, 'py') - compare(script, script2) + compare(script2, script) def test_notebook_with_magic_and_bash_cells(script="""# This is a test for issue #181 @@ -632,7 +632,7 @@ def test_notebook_with_magic_and_bash_cells(script="""# This is a test for issue script2 = jupytext.writes(notebook, 'py') - compare(script, script2) + compare(script2, script) def test_notebook_no_line_to_next_cell(nb=new_notebook( @@ -648,7 +648,7 @@ def test_notebook_no_line_to_next_cell(nb=new_notebook( nb2 = jupytext.reads(script, 'py') nb2.metadata.pop('jupytext') - compare(nb, nb2) + compare(nb2, nb) def test_notebook_one_blank_line_before_first_markdown_cell(script=""" @@ -658,7 +658,7 @@ def test_notebook_one_blank_line_before_first_markdown_cell(script=""" """): notebook = jupytext.reads(script, 'py') script2 = jupytext.writes(notebook, 'py') - compare(script, script2) + compare(script2, script) assert len(notebook.cells) == 3 for cell in notebook.cells: diff --git a/tests/test_read_simple_rmd.py b/tests/test_read_simple_rmd.py index 4fd7a4beb..ec3ebcfad 100644 --- a/tests/test_read_simple_rmd.py +++ b/tests/test_read_simple_rmd.py @@ -58,7 +58,7 @@ def test_read_mostly_py_rmd_file(rmd="""--- rmd2 = jupytext.writes(nb, 'Rmd') rmd2 = re.sub(r'```{r ', '```{r, ', rmd2) rmd2 = re.sub(r'```{python ', '```{python, ', rmd2) - compare(rmd, rmd2) + compare(rmd2, rmd) def test_markdown_cell_with_code_works(nb=new_notebook(cells=[ diff --git a/tests/test_read_simple_scheme.py b/tests/test_read_simple_scheme.py index 5579afc52..83dc5aee7 100644 --- a/tests/test_read_simple_scheme.py +++ b/tests/test_read_simple_scheme.py @@ -25,4 +25,4 @@ def test_read_simple_file(script=""";; --- compare(nb.cells[2].source, '(define a 35)') script2 = jupytext.writes(nb, file_extension) - compare(script, script2) + compare(script2, script) diff --git a/tests/test_read_simple_sphinx.py b/tests/test_read_simple_sphinx.py index 594464d84..bb7826468 100644 --- a/tests/test_read_simple_sphinx.py +++ b/tests/test_read_simple_sphinx.py @@ -48,7 +48,7 @@ def f(x): assert len(nb.cells) == 6 script2 = jupytext.writes(nb, 'py:sphinx') - compare(script, script2) + compare(script2, script) def test_read_more_complex_file(script="""'''This is a markdown cell''' diff --git a/tests/test_read_write_functions.py b/tests/test_read_write_functions.py index 06ff8f134..b8fb082d2 100644 --- a/tests/test_read_write_functions.py +++ b/tests/test_read_write_functions.py @@ -64,7 +64,7 @@ def stream(): nb = jupytext.read(stream()) nb2 = jupytext.read(stream(), fmt='ipynb') - compare(nb, nb2) + compare(nb2, nb) def test_read_py_percent_from_stream(): @@ -75,4 +75,4 @@ def stream(): nb = jupytext.read(stream()) nb2 = jupytext.read(stream(), fmt='py:percent') - compare(nb, nb2) + compare(nb2, nb) diff --git a/tests/test_rmd_to_ipynb.py b/tests/test_rmd_to_ipynb.py index 288b61466..7b88a4403 100644 --- a/tests/test_rmd_to_ipynb.py +++ b/tests/test_rmd_to_ipynb.py @@ -16,7 +16,7 @@ def test_identity_write_read(nb_file, no_jupytext_version_number): nb = jupytext.reads(rmd, 'Rmd') rmd2 = jupytext.writes(nb, 'Rmd') - compare(rmd, rmd2) + compare(rmd2, rmd) def test_two_blank_lines_as_cell_separator():