示例#1
0
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)
示例#5
0
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)
示例#6
0
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)
示例#7
0
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)