From fdc43438eff6ba5e6296041b82d4e417d8fe39ac Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 7 Nov 2017 16:55:02 +0100 Subject: [PATCH] Make tests for non-ASCII files work --- tests/end2end/fixtures/quteprocess.py | 10 ++++++++++ tests/end2end/test_invocations.py | 25 ++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 696febcd4..a2bbd81fd 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -190,6 +190,10 @@ def is_ignored_chromium_message(line): # on receiving Mach ports FFA56F125F699ADB.E28E252911A8704B. Dropping # message. 'Error on receiving Mach ports *. Dropping message.', + + # [2734:2746:1107/131154.072032:ERROR:nss_ocsp.cc(591)] No + # URLRequestContext for NSS HTTP handler. host: ocsp.digicert.com + 'No URLRequestContext for NSS HTTP handler. host: *', ] return any(testutils.pattern_match(pattern=pattern, value=message) for pattern in ignored_messages) @@ -572,6 +576,12 @@ class QuteProc(testprocess.Process): self.wait_for(category='ipc', module='ipc', function='on_ready_read', message='Read from socket *') + def start(self, *args, wait_focus=True, + **kwargs): # pylint: disable=arguments-differ + if not wait_focus: + self._focus_ready = True + super().start(*args, **kwargs) + def send_cmd(self, command, count=None, invalid=False, *, escape=True): """Send a command to the running qutebrowser instance. diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 9abdd73ba..c30768ddb 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -103,20 +103,27 @@ def test_downloads_with_ascii_locale(request, server, tmpdir, quteproc_new): @pytest.mark.linux -def test_open_with_ascii_locale(request, server, tmpdir, quteproc_new): +@pytest.mark.parametrize('url', ['/föö.html', 'file:///föö.html']) +def test_open_with_ascii_locale(request, server, tmpdir, quteproc_new, url): """Test opening non-ascii URL with LC_ALL=C set. https://github.com/qutebrowser/qutebrowser/issues/1450 """ args = ['--temp-basedir'] + _base_args(request.config) quteproc_new.start(args, env={'LC_ALL': 'C'}) + quteproc_new.set_setting('url.auto_search', 'never') # Test opening a file whose name contains non-ascii characters. # No exception thrown means test success. - url = 'file:///föö.html' quteproc_new.send_cmd(':open {}'.format(url)) - quteproc_new.wait_for(category='url', - message='URL contains characters *') + + if not request.config.webengine: + line = quteproc_new.wait_for(message="Error while loading *: Error " + "opening /*: No such file or directory") + line.expected = True + + quteproc_new.wait_for(message="load status for <* tab_id=* " + "url='*/f%C3%B6%C3%B6.html'>: LoadStatus.error") @pytest.mark.linux @@ -130,7 +137,15 @@ def test_open_command_line_with_ascii_locale(request, server, tmpdir, # all be called. No exception thrown means test success. args = (['--temp-basedir'] + _base_args(request.config) + ['/home/user/föö.html']) - quteproc_new.start(args, env={'LC_ALL': 'C'}) + quteproc_new.start(args, env={'LC_ALL': 'C'}, wait_focus=False) + + if not request.config.webengine: + line = quteproc_new.wait_for(message="Error while loading *: Error " + "opening /*: No such file or directory") + line.expected = True + + quteproc_new.wait_for(message="load status for <* tab_id=* " + "url='*/f*.html'>: LoadStatus.error") @pytest.mark.linux