@bdd.when(bdd.parsers.parse('I set up a fake editor returning "{text}"'))
def set_up_editor(quteproc, httpbin, tmpdir, text):
 script = (tmpdir / 'script.py')
 script.write(textwrap.dedent("\n        import sys\n\n        with open(sys.argv[1], 'w', encoding='utf-8') as f:\n            f.write({text!r})\n    ".format(text=text)))
 editor = '"{}" "{}" {{}}'.format(sys.executable, script)
 quteproc.set_setting('general', 'editor', editor)

@ bdd . when ( bdd . parsers . parse ( 'I set up a fake editor returning "{text}"' ) ) def set_up_editor ( quteproc , httpbin , tmpdir , text ) : script = ( tmpdir / 'script.py' ) script . write ( textwrap . dedent ( "\n        import sys\n\n        with open(sys.argv[1], 'w', encoding='utf-8') as f:\n            f.write({text!r})\n    " . format ( text = text ) ) ) editor = '"{}" "{}" {{}}' . format ( sys . executable , script ) quteproc . set_setting ( 'general' , 'editor' , editor )
set up general->editor to a small python script inserting a text .