Skip to content

Commit

Permalink
Tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Oct 28, 2019
1 parent 5bee5c7 commit 6da821c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
5 changes: 3 additions & 2 deletions tests/test_active_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}


Expand Down
10 changes: 5 additions & 5 deletions tests/test_cell_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand All @@ -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)
Expand Down
50 changes: 25 additions & 25 deletions tests/test_read_simple_rmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6da821c

Please sign in to comment.