def test_pipe_into_flake8(): # Notebook OK nb = new_notebook(cells=[new_code_cell('# correct code\n1 + 1')]) pipe_notebook(nb, 'flake8', update=False) # Notebook not OK nb = new_notebook(cells=[new_code_cell('incorrect code')]) with pytest.raises(SystemExit): pipe_notebook(nb, 'flake8', update=False)
def test_pipe_into_isort(): text_org = """# %% import numpy as np np.array([1,2,3]) # %% import pandas as pd pd.Series([1,2,3]) # %% # This is a comment on the second import import pandas as pd pd.Series([4,5,6]) """ text_target = """# %% import numpy as np # This is a comment on the second import import pandas as pd np.array([1,2,3]) # %% pd.Series([1,2,3]) # %% pd.Series([4,5,6]) """ nb_org = reads(text_org, fmt="py:percent") nb_pipe = pipe_notebook( nb_org, 'isort - --treat-comment-as-code "# %%" --float-to-top') text_actual = writes(nb_pipe, "py:percent") compare(text_actual, text_target)
def test_pipe_into_autopep8(): nb_org = new_notebook(cells=[new_code_cell("1 +1", id="cell-id")]) nb_dest = new_notebook(cells=[new_code_cell("1 + 1", id="cell-id")]) nb_pipe = pipe_notebook(nb_org, "autopep8 -") compare_notebooks(nb_pipe, nb_dest, allow_expected_differences=False, compare_ids=True)
def test_pipe_into_autopep8(): nb_org = new_notebook(cells=[new_code_cell('1 +1')]) nb_dest = new_notebook(cells=[new_code_cell('1 + 1')]) nb_pipe = pipe_notebook(nb_org, 'autopep8 -') compare(nb_dest, nb_pipe)
def test_pipe_into_black(): nb_org = new_notebook(cells=[new_code_cell('1 +1')]) nb_dest = new_notebook(cells=[new_code_cell('1 + 1')]) nb_pipe = pipe_notebook(nb_org, 'black') compare(nb_dest, nb_pipe)
def test_pipe_into_autopep8(): nb_org = new_notebook(cells=[new_code_cell("1 +1")]) nb_dest = new_notebook(cells=[new_code_cell("1 + 1")]) nb_pipe = pipe_notebook(nb_org, "autopep8 -") compare(nb_pipe, nb_dest)
def test_pipe_into_black(): nb_org = new_notebook(cells=[new_code_cell("1 +1")]) nb_dest = new_notebook(cells=[new_code_cell("1 + 1")]) nb_pipe = pipe_notebook(nb_org, "black") compare(nb_pipe, nb_dest)