summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2016-12-28 23:03:46 +0100
committerFlorian Bruhin <git@the-compiler.org>2016-12-28 23:03:46 +0100
commitd9c8bd7fca349c665c05c0eb46089aa221f1943e (patch)
tree865df572c38aa2624fba39243d7cf3d7067db42f
parent864b9870a5dd0bcfe1b97c74e70259e10d294c05 (diff)
downloadqutebrowser-d9c8bd7fca349c665c05c0eb46089aa221f1943e.tar.gz
qutebrowser-d9c8bd7fca349c665c05c0eb46089aa221f1943e.zip
Add a test for userscript unicode errors
-rw-r--r--tests/unit/commands/test_userscripts.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/commands/test_userscripts.py b/tests/unit/commands/test_userscripts.py
index 778270551..5212b0d32 100644
--- a/tests/unit/commands/test_userscripts.py
+++ b/tests/unit/commands/test_userscripts.py
@@ -227,6 +227,24 @@ def test_temporary_files_failed_cleanup(caplog, qtbot, py_proc, runner):
assert caplog.records[0].message.startswith(expected)
+def test_unicode_error(caplog, qtbot, py_proc, runner):
+ cmd, args = py_proc(r"""
+ import os
+ with open(os.environ['QUTE_FIFO'], 'wb') as f:
+ f.write(b'\x80')
+ """)
+ with caplog.at_level(logging.ERROR):
+ with qtbot.waitSignal(runner.finished, timeout=10000):
+ runner.prepare_run(cmd, *args)
+ runner.store_text('')
+ runner.store_html('')
+
+ assert len(caplog.records) == 1
+ expected = ("Invalid unicode in userscript output: 'utf-8' codec can't "
+ "decode byte 0x80 in position 0: invalid start byte")
+ assert caplog.records[0].message == expected
+
+
def test_unsupported(monkeypatch, tabbed_browser_stubs):
monkeypatch.setattr(userscripts.os, 'name', 'toaster')
with pytest.raises(userscripts.UnsupportedError) as excinfo: