@@ -143,46 +143,16 @@ def aiida_profile(pytestconfig, aiida_config, aiida_profile_factory, config_psql
143143
144144@pytest .fixture ()
145145def non_interactive_editor (request ):
146- """Fixture to patch click's `Editor.edit_file` .
146+ """Fixture to patch default editor .
147147
148- In `click==7.1` the `Editor.edit_file` command was changed to escape the `os.environ['EDITOR']` command. Our tests
149- are currently abusing this variable to define an automated vim command in order to make an interactive command
150- non-interactive, and escaping it makes bash interpret the command and its arguments as a single command instead.
151- Here we patch the method to remove the escaping of the editor command.
148+ We (ab)use the `os.environ['EDITOR']` variable to define an automated
149+ vim command in order to make an interactive command non-interactive
152150
153151 :param request: the command to set for the editor that is to be called
154152 """
155- from unittest .mock import patch
156-
157- from click ._termui_impl import Editor
158-
159153 os .environ ['EDITOR' ] = request .param
160154 os .environ ['VISUAL' ] = request .param
161155
162- def edit_file (self , filename ):
163- import subprocess
164-
165- editor = self .get_editor ()
166- if self .env :
167- environ = os .environ .copy ()
168- environ .update (self .env )
169- else :
170- environ = None
171- try :
172- with subprocess .Popen (
173- f'{ editor } { filename } ' , # This is the line that we change removing `shlex_quote`
174- env = environ ,
175- shell = True ,
176- ) as process :
177- exit_code = process .wait ()
178- if exit_code != 0 :
179- raise click .ClickException (f'{ editor } : Editing failed!' )
180- except OSError as exception :
181- raise click .ClickException (f'{ editor } : Editing failed: { exception } ' )
182-
183- with patch .object (Editor , 'edit_file' , edit_file ):
184- yield
185-
186156
187157@pytest .fixture (scope = 'function' )
188158def fixture_sandbox ():
0 commit comments