def go(check_call, exists): test_environ = {"PATH": os.pathsep.join(["/usr/bin", "/bin"])} executable = join("/bin", "vim") exists.side_effect = lambda fname: fname == executable util.open_in_editor("myfile", test_environ) check_call.assert_called_with([executable, "myfile"])
def go(check_call, exists): test_environ = {"EDITOR": "myvim", "PATH": "/usr/bin"} executable = join("/usr/bin", "myvim") if not posix: executable += ".exe" exists.side_effect = lambda fname: fname == executable util.open_in_editor("myfile", test_environ) check_call.assert_called_with([executable, "myfile"])
def go(check_call, exists): test_environ = { "PATH": os.pathsep.join( [r"C:\Windows\System32", r"C:\Users\user\bin"] ) } executable = join(r"C:\Users\user\bin", "notepad.exe") exists.side_effect = lambda fname: fname == executable util.open_in_editor("myfile", test_environ) check_call.assert_called_with([executable, "myfile"])
def go(check_call, exists): test_environ = { "EDITOR": "myvim", "VISUAL": "myvisual", "PATH": "/usr/bin", } exes = ["myvim", "myvisual"] if with_path: exes = [join("/usr/bin", n) for n in exes] exists.side_effect = lambda fname: fname in exes util.open_in_editor("myfile", test_environ) check_call.assert_called_with([exes[0], "myfile"])
def go(check_call, exists): test_environ = {} exists.return_value = False with expect_raises_message(util.CommandError, "EDITOR"): util.open_in_editor("myfile", test_environ)
def go(check_call, exists): test_environ = {"EDITOR": "/foo/myvim", "PATH": "/usr/bin"} exists.side_effect = lambda fname: fname == "/usr/bin/foo/myvim" with expect_raises_message(util.CommandError, "EDITOR"): util.open_in_editor("myfile", test_environ)
def go(check_call, exists): test_environ = {key: "myvim", "PATH": "/usr/bin"} exists.side_effect = lambda fname: fname == "myvim" util.open_in_editor("myfile", test_environ) check_call.assert_called_with(["myvim", "myfile"])