Exemplo n.º 1
0
def test_next_instruction_is_function_or_class():
    text = """@pytest.mark.parametrize('py_file',
    [py_file for py_file in list_notebooks('../jupytext') + list_notebooks('.') if
                                     py_file.endswith('.py')])
def test_no_metadata_when_py_is_pep8(py_file):
    pass
"""
    assert next_instruction_is_function_or_class(text.splitlines())
Exemplo n.º 2
0
def test_pep8_lines_between_cells():
    prev_lines = """a = a_long_instruction(
    over_two_lines=True)""".splitlines()

    next_lines = """def f(x):
    return x""".splitlines()

    assert cell_ends_with_code(prev_lines)
    assert next_instruction_is_function_or_class(next_lines)
    assert pep8_lines_between_cells(prev_lines, next_lines, ".py") == 2
Exemplo n.º 3
0
def test_pep8_lines_between_cells_ter():
    prev_lines = ["from jupytext.cell_to_text import RMarkdownCellExporter"]

    next_lines = '''@pytest.mark.parametrize(
    "lines",
    [
        "# text",
        """# # %%R
# # comment
# 1 + 1
# 2 + 2
""",
    ],
)
def test_paragraph_is_fully_commented(lines):
    assert paragraph_is_fully_commented(
        lines.splitlines(), comment="#", main_language="python"
    )'''.splitlines()

    assert cell_ends_with_code(prev_lines)
    assert next_instruction_is_function_or_class(next_lines)
    assert pep8_lines_between_cells(prev_lines, next_lines, ".py") == 2