Restructure test_prompt
This commit is contained in:
parent
60c6b7f0ab
commit
bbd8cc56a2
@ -17,6 +17,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from qutebrowser.mainwindow import prompt as promptmod
|
from qutebrowser.mainwindow import prompt as promptmod
|
||||||
@ -28,24 +30,36 @@ def setup(qapp, key_config_stub):
|
|||||||
key_config_stub.set_bindings_for('prompt', {})
|
key_config_stub.set_bindings_for('prompt', {})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('steps, where, subfolder', [
|
class TestFileCompletion:
|
||||||
(1, 'next', '..'),
|
|
||||||
(1, 'prev', 'c'),
|
@pytest.fixture
|
||||||
(2, 'next', 'a'),
|
def get_prompt(self, qtbot):
|
||||||
(2, 'prev', 'b'),
|
def _get_prompt_func(path):
|
||||||
])
|
|
||||||
def test_file_completion(tmpdir, qtbot, steps, where, subfolder):
|
|
||||||
for directory in 'abc':
|
|
||||||
(tmpdir / directory).ensure(dir=True)
|
|
||||||
question = usertypes.Question()
|
question = usertypes.Question()
|
||||||
question.title = "test"
|
question.title = "test"
|
||||||
question.default = str(tmpdir) + '/'
|
question.default = path
|
||||||
|
|
||||||
prompt = promptmod.DownloadFilenamePrompt(question)
|
prompt = promptmod.DownloadFilenamePrompt(question)
|
||||||
qtbot.add_widget(prompt)
|
qtbot.add_widget(prompt)
|
||||||
with qtbot.wait_signal(prompt._file_model.directoryLoaded):
|
with qtbot.wait_signal(prompt._file_model.directoryLoaded):
|
||||||
pass
|
pass
|
||||||
assert prompt._lineedit.text() == str(tmpdir) + '/'
|
assert prompt._lineedit.text() == path
|
||||||
|
|
||||||
|
return prompt
|
||||||
|
return _get_prompt_func
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('steps, where, subfolder', [
|
||||||
|
(1, 'next', '..'),
|
||||||
|
(1, 'prev', 'c'),
|
||||||
|
(2, 'next', 'a'),
|
||||||
|
(2, 'prev', 'b'),
|
||||||
|
])
|
||||||
|
def test_simple_completion(self, tmpdir, get_prompt, steps, where,
|
||||||
|
subfolder):
|
||||||
|
for directory in 'abc':
|
||||||
|
(tmpdir / directory).ensure(dir=True)
|
||||||
|
|
||||||
|
prompt = get_prompt(str(tmpdir) + os.sep)
|
||||||
|
|
||||||
for _ in range(steps):
|
for _ in range(steps):
|
||||||
prompt.item_focus(where)
|
prompt.item_focus(where)
|
||||||
|
Loading…
Reference in New Issue
Block a user