Skip to content

Commit

Permalink
Merge pull request #10819 from q0w/file404
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Feb 3, 2022
2 parents f8bd9c9 + 7f6a9ca commit ec8edbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions news/10812.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve error message when ``pip config edit`` is provided an editor that
doesn't exist.
4 changes: 4 additions & 0 deletions src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def open_in_editor(self, options: Values, args: List[str]) -> None:

try:
subprocess.check_call([editor, fname])
except FileNotFoundError as e:
if not e.filename:
e.filename = editor
raise
except subprocess.CalledProcessError as e:
raise PipError(
"Editor Subprocess exited with exit code {}".format(e.returncode)
Expand Down
7 changes: 7 additions & 0 deletions tests/functional/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,10 @@ def test_global_config_file(self, script: PipTestEnvironment) -> None:
global_config_file = get_configuration_files()[kinds.GLOBAL][0]
result = script.pip("config", "debug")
assert f"{global_config_file}, exists:" in result.stdout

def test_editor_does_not_exist(self, script: PipTestEnvironment) -> None:
"""Ensure that FileNotFoundError sets filename correctly"""
result = script.pip(
"config", "edit", "--editor", "notrealeditor", expect_error=True
)
assert "notrealeditor" in result.stderr

0 comments on commit ec8edbf

Please sign in to comment.