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"]
def test_escape(line): assert comment_magic([line]) == ["# " + line] assert uncomment_magic(comment_magic([line])) == [line]
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]
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]
def test_comment_bash_commands_in_python(magic_cmd): assert comment_magic([magic_cmd]) == ["# " + magic_cmd] assert uncomment_magic(["# " + magic_cmd]) == [magic_cmd]
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
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
def test_comment_bash_commands_in_python(magic_cmd): comment_magic([magic_cmd]) == ['# ' + magic_cmd] uncomment_magic(['# ' + magic_cmd]) == magic_cmd