summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/test/util/editor.py14
-rw-r--r--lib/spack/spack/util/editor.py2
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/spack/spack/test/util/editor.py b/lib/spack/spack/test/util/editor.py
index e7c8bf2364..54b1c251fe 100644
--- a/lib/spack/spack/test/util/editor.py
+++ b/lib/spack/spack/test/util/editor.py
@@ -132,3 +132,17 @@ def test_editor_both_bad(nosuch_exe, vim_exe):
assert args == [vim_exe, '/path/to/file']
ed.editor('/path/to/file', _exec_func=assert_exec)
+
+
+def test_no_editor():
+ if 'VISUAL' in os.environ:
+ del os.environ['VISUAL']
+ if 'EDITOR' in os.environ:
+ del os.environ['EDITOR']
+ os.environ['PATH'] = ''
+
+ def assert_exec(exe, args):
+ assert False
+
+ with pytest.raises(EnvironmentError, match=r'No text editor found.*'):
+ ed.editor('/path/to/file', _exec_func=assert_exec)
diff --git a/lib/spack/spack/util/editor.py b/lib/spack/spack/util/editor.py
index e3f740adac..58198907af 100644
--- a/lib/spack/spack/util/editor.py
+++ b/lib/spack/spack/util/editor.py
@@ -122,7 +122,7 @@ def editor(*args, **kwargs):
# trying them all -- if we get here and one fails, something is
# probably much more deeply wrong with the environment.
exe = which_string(*_default_editors)
- if try_exec(exe, [exe] + list(args)):
+ if exe and try_exec(exe, [exe] + list(args)):
return
# Fail if nothing could be found