Esempio n. 1
0
def test_text_to_code_cell_empty_code_no_blank_line():
    text = """```{python}
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader().read(lines)

    assert cell.cell_type == "code"
    assert cell.source == ""
    assert cell.metadata == {"language": "python"}
    assert lines[pos:] == []
Esempio n. 2
0
def test_text_to_code_cell_empty_code_no_blank_line():
    text = """```{python}
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader('.Rmd').read(lines)

    assert cell.cell_type == 'code'
    assert cell.source == ''
    assert cell.metadata == {'language': 'python'}
    assert lines[pos:] == []
Esempio n. 3
0
def test_text_to_code_cell():
    text = """```{python}
1+2+3
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader().read(lines)

    assert cell.cell_type == 'code'
    assert cell.source == '1+2+3'
    assert cell.metadata == {'language': 'python'}
    assert lines[pos:] == []
Esempio n. 4
0
def test_text_to_markdown_one_blank_line():
    text = """
```{python}
1+2+3
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader().read(lines)

    assert cell.cell_type == "markdown"
    assert cell.source == ""
    assert cell.metadata == {"lines_to_next_cell": 0}
    assert pos == 1
Esempio n. 5
0
def test_text_to_markdown_two_blank_line():
    text = """

```{python}
1+2+3
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader('.Rmd').read(lines)

    assert cell.cell_type == 'markdown'
    assert cell.source == ''
    assert cell.metadata == {}
    assert pos == 2
Esempio n. 6
0
def test_text_to_markdown_no_blank_line():
    text = """This is
a markdown cell
```{python}
1+2+3
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader('.Rmd').read(lines)

    assert cell.cell_type == 'markdown'
    assert cell.source == 'This is\na markdown cell'
    assert cell.metadata == {'lines_to_next_cell': 0}
    assert pos == 2
Esempio n. 7
0
def test_text_to_markdown_cell():
    text = """This is
a markdown cell

```{python}
1+2+3
```
"""
    lines = text.splitlines()
    cell, pos = RMarkdownCellReader().read(lines)

    assert cell.cell_type == "markdown"
    assert cell.source == "This is\na markdown cell"
    assert cell.metadata == {}
    assert pos == 3