Пример #1
0
def test_indented_magic():
    assert is_magic("    !rm file", "python")
    assert is_magic("    # !rm file", "python")
    assert is_magic("    %cd", "python")
    assert comment_magic(["    !rm file"]) == ["    # !rm file"]
    assert uncomment_magic(["    # !rm file"]) == ["    !rm file"]
    assert comment_magic(["    %cd"]) == ["    # %cd"]
    assert uncomment_magic(["    # %cd"]) == ["    %cd"]
Пример #2
0
def test_force_escape_with_gbl_esc_flag(line):
    assert comment_magic([line], global_escape_flag=False) == ["# " + line]
Пример #3
0
def test_force_noescape_with_gbl_esc_flag(line):
    assert comment_magic([line], global_escape_flag=True) == [line]
Пример #4
0
def test_force_noescape(line):
    assert comment_magic([line]) == [line]
Пример #5
0
def test_escape_magic_only(line):
    assert comment_magic([line]) == [line]
Пример #6
0
def test_escape(line):
    assert comment_magic([line]) == ["# " + line]
    assert uncomment_magic(comment_magic([line])) == [line]
Пример #7
0
def test_do_not_comment_bash_commands_in_R(magic_cmd):
    assert comment_magic([magic_cmd], language="R") == [magic_cmd]
    assert uncomment_magic([magic_cmd], language="R") == [magic_cmd]
Пример #8
0
def test_do_not_comment_python_cmds(not_magic_cmd):
    assert comment_magic([not_magic_cmd]) == [not_magic_cmd]
    assert uncomment_magic([not_magic_cmd]) == [not_magic_cmd]
Пример #9
0
def test_comment_bash_commands_in_python(magic_cmd):
    assert comment_magic([magic_cmd]) == ["# " + magic_cmd]
    assert uncomment_magic(["# " + magic_cmd]) == [magic_cmd]
Пример #10
0
def test_do_not_comment_bash_commands_in_R(magic_cmd):
    comment_magic([magic_cmd], language='R') == ['# ' + magic_cmd]
    uncomment_magic(['# ' + magic_cmd], language='R') == magic_cmd
Пример #11
0
def test_do_not_comment_python_cmds(not_magic_cmd):
    comment_magic([not_magic_cmd]) == [not_magic_cmd]
    uncomment_magic([not_magic_cmd]) == not_magic_cmd
Пример #12
0
def test_comment_bash_commands_in_python(magic_cmd):
    comment_magic([magic_cmd]) == ['# ' + magic_cmd]
    uncomment_magic(['# ' + magic_cmd]) == magic_cmd
Пример #13
0
def test_force_escape(line):
    assert comment_magic([line]) == ['# ' + line]