From 89a507a0bbb403bd25521522d1821cae96fe1ca6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 27 May 2014 11:17:27 +0200 Subject: [PATCH] Add ArgTests --- qutebrowser/test/utils/test_editor.py | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/qutebrowser/test/utils/test_editor.py b/qutebrowser/test/utils/test_editor.py index e510f1ae9..ce71fc4c0 100644 --- a/qutebrowser/test/utils/test_editor.py +++ b/qutebrowser/test/utils/test_editor.py @@ -67,6 +67,39 @@ def setUpModule(): editor.QProcess = FakeQProcess +class ArgTests(TestCase): + + """Test argument handling.""" + + def setUp(self): + self.editor = editor.ExternalEditor() + self.editor.editing_finished = Mock() + + def test_simple_start(self): + """Test starting editor with static arguments.""" + editor.config = ConfigStub(editor=["executable", "foo", "bar"]) + self.editor.edit("") + self.editor.proc.start.assert_called_with("executable", ["foo", "bar"]) + self.editor.on_proc_closed(0, QProcess.NormalExit) + + def test_placeholder(self): + """Test starting editor with placeholder argument.""" + editor.config = ConfigStub(editor=["executable", "foo", "{}", "bar"]) + self.editor.edit("") + filename = self.editor.filename + self.editor.proc.start.assert_called_with( + "executable", ["foo", filename, "bar"]) + self.editor.on_proc_closed(0, QProcess.NormalExit) + + def test_in_arg_placeholder(self): + """Test starting editor with placeholder argument inside argument.""" + editor.config = ConfigStub(editor=["executable", "foo{}bar"]) + self.editor.edit("") + filename = self.editor.filename + self.editor.proc.start.assert_called_with("executable", ["foo{}bar"]) + self.editor.on_proc_closed(0, QProcess.NormalExit) + + class FileHandlingTests(TestCase): """Test creation/deletion of tempfile."""