summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2017-07-03 09:40:39 +0200
committerFlorian Bruhin <git@the-compiler.org>2017-07-03 10:07:40 +0200
commit3b53ec1cb6c136ffb12e46f3b532e546cb0bd421 (patch)
treec9fb5f294368a959fe28ee98f0296e5449646fe1
parent2f264905369193d1416925415abf2fc1a4c0e289 (diff)
downloadqutebrowser-3b53ec1cb6c136ffb12e46f3b532e546cb0bd421.tar.gz
qutebrowser-3b53ec1cb6c136ffb12e46f3b532e546cb0bd421.zip
Skip tests with permission changes if they didn't work
This e.g. wouldn't work inside of a Docker container otherwise.
-rw-r--r--tests/end2end/features/downloads.feature4
-rw-r--r--tests/end2end/features/test_downloads_bdd.py9
-rw-r--r--tests/unit/misc/test_editor.py10
3 files changed, 19 insertions, 4 deletions
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):