From 6da821c1b653e9a7a61cc102331e6958d9cfb50e Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Mon, 28 Oct 2019 23:38:46 +0100 Subject: [PATCH] Tests updated #337 --- tests/test_active_cells.py | 5 ++-- tests/test_cell_metadata.py | 10 +++---- tests/test_read_simple_rmd.py | 50 +++++++++++++++++------------------ 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/tests/test_active_cells.py b/tests/test_active_cells.py index 5ce8618f0..f4ec96206 100644 --- a/tests/test_active_cells.py +++ b/tests/test_active_cells.py @@ -233,20 +233,21 @@ def test_active_rmd(ext, no_jupytext_version_number): compare(nb.cells[0], ACTIVE_RMD['.ipynb']) -ACTIVE_NOT_INCLUDE_RMD = {'.py': """# + hide_output=true active="Rmd" +ACTIVE_NOT_INCLUDE_RMD = {'.py': """# + hide_input=true hide_output=true active="Rmd" # # This cell is active in Rmd only """, '.Rmd': """```{python include=FALSE, active="Rmd"} # This cell is active in Rmd only ``` """, - '.R': """# + hide_output=true active="Rmd" + '.R': """# + hide_input=true hide_output=true active="Rmd" # # This cell is active in Rmd only """, '.ipynb': {'cell_type': 'raw', 'source': '# This cell is active in Rmd only', 'metadata': {'active': 'Rmd', + 'hide_input': True, 'hide_output': True}}} diff --git a/tests/test_cell_metadata.py b/tests/test_cell_metadata.py index 485fb5301..c2ffe5eb1 100644 --- a/tests/test_cell_metadata.py +++ b/tests/test_cell_metadata.py @@ -15,7 +15,7 @@ ('r echo=FALSE', ('R', {'hide_input': True})), ('r plot_1, echo=TRUE', - ('R', {'name': 'plot_1', 'hide_input': False})), + ('R', {'name': 'plot_1', 'echo': True})), ('python echo=if a==5 then TRUE else FALSE', ('python', {'echo': 'if a==5 then TRUE else FALSE'})), ('python noname, tags=c("a", "b", "c"), echo={sum(a+c(1,2))>1}', @@ -24,23 +24,23 @@ ('python active="ipynb,py"', ('python', {'active': 'ipynb,py'})), ('python include=FALSE, active="Rmd"', - ('python', {'active': 'Rmd', 'hide_output': True})), + ('python', {'active': 'Rmd', 'hide_output': True, 'hide_input': True})), ('r chunk_name, include=FALSE, active="Rmd"', ('R', - {'name': 'chunk_name', 'active': 'Rmd', 'hide_output': True})), + {'name': 'chunk_name', 'active': 'Rmd', 'hide_output': True, 'hide_input': True})), ('python tags=c("parameters")', ('python', {'tags': ['parameters']}))] @pytest.mark.parametrize('options,language_and_metadata', SAMPLES) def test_parse_rmd_options(options, language_and_metadata): - assert rmd_options_to_metadata(options) == language_and_metadata + compare(rmd_options_to_metadata(options), language_and_metadata) @skip_if_dict_is_not_ordered @pytest.mark.parametrize('options,language_and_metadata', SAMPLES) def test_build_options(options, language_and_metadata): - assert metadata_to_rmd_options(*language_and_metadata) == options + compare(metadata_to_rmd_options(*language_and_metadata), options) @pytest.mark.parametrize('options,language_and_metadata', SAMPLES) diff --git a/tests/test_read_simple_rmd.py b/tests/test_read_simple_rmd.py index 75a9e2072..4fd7a4beb 100644 --- a/tests/test_read_simple_rmd.py +++ b/tests/test_read_simple_rmd.py @@ -29,31 +29,31 @@ def test_read_mostly_py_rmd_file(rmd="""--- ``` """): nb = jupytext.reads(rmd, 'Rmd') - assert nb.cells == [{'cell_type': 'raw', - 'source': '---\ntitle: Simple file\n---', - 'metadata': {}}, - {'cell_type': 'code', - 'metadata': {'hide_input': False}, - 'execution_count': None, - 'source': 'import numpy as np\n' - 'x = np.arange(0, 2*math.pi, eps)', - 'outputs': []}, - {'cell_type': 'code', - 'metadata': {'hide_input': False}, - 'execution_count': None, - 'source': 'x = np.arange(0,1,eps)\ny = np.abs(x)-.5', - 'outputs': []}, - {'cell_type': 'code', - 'metadata': {}, - 'execution_count': None, - 'source': '%%R\nls()', - 'outputs': []}, - {'cell_type': 'code', - 'metadata': {'results': "'asis'"}, - 'execution_count': None, - 'source': "%%R -i x\ncat(stringi::" - "stri_rand_lipsum(3), sep='\n\n')", - 'outputs': []}] + compare(nb.cells, [{'cell_type': 'raw', + 'source': '---\ntitle: Simple file\n---', + 'metadata': {}}, + {'cell_type': 'code', + 'metadata': {'echo': True}, + 'execution_count': None, + 'source': 'import numpy as np\n' + 'x = np.arange(0, 2*math.pi, eps)', + 'outputs': []}, + {'cell_type': 'code', + 'metadata': {'echo': True}, + 'execution_count': None, + 'source': 'x = np.arange(0,1,eps)\ny = np.abs(x)-.5', + 'outputs': []}, + {'cell_type': 'code', + 'metadata': {}, + 'execution_count': None, + 'source': '%%R\nls()', + 'outputs': []}, + {'cell_type': 'code', + 'metadata': {'results': "'asis'"}, + 'execution_count': None, + 'source': "%%R -i x\ncat(stringi::" + "stri_rand_lipsum(3), sep='\n\n')", + 'outputs': []}]) rmd2 = jupytext.writes(nb, 'Rmd') rmd2 = re.sub(r'```{r ', '```{r, ', rmd2)