summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-11 19:42:39 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-03-11 19:42:39 +0100
commit85d38e8db9627a880afae55376b2673c85c3cf77 (patch)
tree22716c7d44902d397401dc247bdc5b1f18c6f4b8
parent648b90a719622f575a009e2996648e3b8a8c3192 (diff)
parent3707234c3ae95c9ee7cc0721b668a5e96a9cfa6f (diff)
downloadqutebrowser-85d38e8db9627a880afae55376b2673c85c3cf77.tar.gz
qutebrowser-85d38e8db9627a880afae55376b2673c85c3cf77.zip
Merge remote-tracking branch 'origin/pr/6253'
-rw-r--r--tests/unit/commands/test_userscripts.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/unit/commands/test_userscripts.py b/tests/unit/commands/test_userscripts.py
index 48bc31c32..436e9e2a7 100644
--- a/tests/unit/commands/test_userscripts.py
+++ b/tests/unit/commands/test_userscripts.py
@@ -18,6 +18,7 @@
# along with qutebrowser. If not, see <https://www.gnu.org/licenses/>.
import os
+import pathlib
import json
import time
import logging
@@ -34,8 +35,8 @@ from qutebrowser.utils import utils
class TestQtFIFOReader:
@pytest.fixture
- def reader(self, tmpdir, qapp):
- fifo_path = str(tmpdir / 'fifo')
+ def reader(self, tmp_path, qapp):
+ fifo_path = str(tmp_path / 'fifo')
os.mkfifo(fifo_path) # pylint: disable=no-member,useless-suppression
reader = userscripts._QtFIFOReader(fifo_path)
yield reader
@@ -142,8 +143,8 @@ def test_source(qtbot, py_proc, runner):
assert parsed['text'] == 'This is text'
assert parsed['html'] == 'This is HTML'
- assert not os.path.exists(parsed['text_file'])
- assert not os.path.exists(parsed['html_file'])
+ assert not pathlib.Path(parsed['text_file']).exists()
+ assert not pathlib.Path(parsed['html_file']).exists()
def test_command_with_error(qtbot, py_proc, runner, caplog):
@@ -165,13 +166,13 @@ def test_command_with_error(qtbot, py_proc, runner, caplog):
runner.store_html('')
data = json.loads(blocker.args[0])
- assert not os.path.exists(data)
+ assert not pathlib.Path(data).exists()
-def test_killed_command(qtbot, tmpdir, py_proc, runner, caplog):
- data_file = tmpdir / 'data'
+def test_killed_command(qtbot, tmp_path, py_proc, runner, caplog):
+ data_file = tmp_path / 'data'
watcher = QFileSystemWatcher()
- watcher.addPath(str(tmpdir))
+ watcher.addPath(str(tmp_path))
cmd, args = py_proc(r"""
import os
@@ -203,13 +204,14 @@ def test_killed_command(qtbot, tmpdir, py_proc, runner, caplog):
# Make sure the PID was written to the file, not just the file created
time.sleep(0.5)
- data = json.load(data_file)
+ with data_file.open() as f:
+ data = json.load(f)
with caplog.at_level(logging.ERROR):
with qtbot.wait_signal(runner.finished):
os.kill(int(data['pid']), signal.SIGTERM)
- assert not os.path.exists(data['text_file'])
+ assert not pathlib.Path(data['text_file']).exists()
def test_temporary_files_failed_cleanup(caplog, qtbot, py_proc, runner):