From 29dc1f636d436a4c4b0409d797e5ff7357ee73e3 Mon Sep 17 00:00:00 2001 From: Jason Rosenzweig Date: Thu, 15 Jul 2021 16:49:37 +0800 Subject: No more '..' in the file prompt (#2104) --- qutebrowser/mainwindow/prompt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index c8cbe572b..1671ed46f 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -795,7 +795,7 @@ class DownloadFilenamePrompt(FilenamePrompt): def __init__(self, question, parent=None): super().__init__(question, parent) self._file_model.setFilter( - QDir.AllDirs | QDir.Drives | QDir.NoDot) # type: ignore[arg-type] + QDir.AllDirs | QDir.Drives | QDir.NoDotAndDotDot) # type: ignore[arg-type] def accept(self, value=None, save=False): done = super().accept(value, save) -- cgit v1.2.3-54-g00ecf From 6223a41a3c61d7eca8021b3bad5f74210eeab052 Mon Sep 17 00:00:00 2001 From: Jason Rosenzweig Date: Thu, 15 Jul 2021 22:06:52 +0800 Subject: Fixed failing tests --- tests/unit/mainwindow/test_prompt.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py index 5b774bdaa..fabf68a89 100644 --- a/tests/unit/mainwindow/test_prompt.py +++ b/tests/unit/mainwindow/test_prompt.py @@ -48,9 +48,8 @@ class TestFileCompletion: return _get_prompt_func @pytest.mark.parametrize('steps, where, subfolder', [ - (1, 'next', '..'), - (1, 'prev', 'c'), - (2, 'next', 'a'), + (1, 'next', 'a'), + (2, 'next', 'b'), (2, 'prev', 'b'), ]) def test_simple_completion(self, tmp_path, get_prompt, steps, where, @@ -84,9 +83,7 @@ class TestFileCompletion: # For some reason, this isn't always called when using qtbot.keyPress. prompt._set_fileview_root(prompt._lineedit.text()) - # '..' and 'foo' should get completed from 'f' - prompt.item_focus('next') - assert prompt._lineedit.text() == str(tmp_path) + # 'foo' should get completed from 'f' prompt.item_focus('next') assert prompt._lineedit.text() == str(testdir / 'foo') @@ -94,15 +91,15 @@ class TestFileCompletion: for _ in range(3): qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace) - # We should now show / again, so tabbing twice gives us .. -> bar + # We should now show / again, so tabbing twice gives us bar -> foo prompt.item_focus('next') prompt.item_focus('next') - assert prompt._lineedit.text() == str(testdir / 'bar') + assert prompt._lineedit.text() == str(testdir / 'foo') @pytest.mark.parametrize("keys, expected", [ - ([], ['..', 'bar', 'bat', 'foo']), - ([Qt.Key_F], ['..', 'foo']), - ([Qt.Key_A], ['..', 'bar', 'bat']), + ([], ['bar', 'bat', 'foo']), + ([Qt.Key_F], ['foo']), + ([Qt.Key_A], ['bar', 'bat']), ]) def test_filtering_path(self, qtbot, tmp_path, get_prompt, keys, expected): testdir = tmp_path / 'test' -- cgit v1.2.3-54-g00ecf