diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature index 95b775303..07e062610 100644 --- a/tests/end2end/features/downloads.feature +++ b/tests/end2end/features/downloads.feature @@ -579,9 +579,9 @@ Feature: Downloading things from a website. And I wait until the download is finished Then the downloaded file content-size should exist - @posix Scenario: Downloading to unwritable destination - When I set storage -> prompt-download-directory to false + When the unwritable dir is unwritable + And I set storage -> prompt-download-directory to false And I run :download http://localhost:(port)/data/downloads/download.bin --dest (tmpdir)/downloads/unwritable Then the error "Download error: Permission denied" should be shown diff --git a/tests/end2end/features/test_downloads_bdd.py b/tests/end2end/features/test_downloads_bdd.py index 25eb52aad..4be175a66 100644 --- a/tests/end2end/features/test_downloads_bdd.py +++ b/tests/end2end/features/test_downloads_bdd.py @@ -21,6 +21,7 @@ import os import sys import shlex +import pytest import pytest_bdd as bdd bdd.scenarios('downloads.feature') @@ -53,6 +54,14 @@ def clean_old_downloads(quteproc): quteproc.send_cmd(':download-clear') +@bdd.when("the unwritable dir is unwritable") +def check_unwritable(tmpdir): + unwritable = tmpdir / 'downloads' / 'unwritable' + if os.access(str(unwritable), os.W_OK): + # Docker container or similar + pytest.skip("Unwritable dir was writable") + + @bdd.when("I wait until the download is finished") def wait_for_download_finished(quteproc): quteproc.wait_for(category='downloads', message='Download * finished') diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py index de9125c8b..70886cda6 100644 --- a/tests/unit/misc/test_editor.py +++ b/tests/unit/misc/test_editor.py @@ -123,24 +123,30 @@ class TestFileHandling: os.remove(filename) - @pytest.mark.posix def test_unreadable(self, message_mock, editor, caplog): """Test file handling when closing with an unreadable file.""" editor.edit("") filename = editor._file.name assert os.path.exists(filename) os.chmod(filename, 0o077) + if os.access(filename, os.R_OK): + # Docker container or similar + pytest.skip("File was still readable") + with caplog.at_level(logging.ERROR): editor._proc.finished.emit(0, QProcess.NormalExit) assert not os.path.exists(filename) msg = message_mock.getmsg(usertypes.MessageLevel.error) assert msg.text.startswith("Failed to read back edited file: ") - @pytest.mark.posix def test_unwritable(self, monkeypatch, message_mock, editor, tmpdir, caplog): """Test file handling when the initial file is not writable.""" tmpdir.chmod(0) + if os.access(str(tmpdir), os.W_OK): + # Docker container or similar + pytest.skip("File was still writable") + monkeypatch.setattr(editormod.tempfile, 'tempdir', str(tmpdir)) with caplog.at_level(logging.ERROR):