Make tests for non-ASCII files work

This commit is contained in:
Florian Bruhin 2017-11-07 16:55:02 +01:00
parent 743dbbbcd6
commit fdc43438ef
2 changed files with 30 additions and 5 deletions

View File

@ -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.

View File

@ -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