From 4887385bdd47fffd1b0695cfb8e401fe8cb90dd8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 21 Jun 2018 01:40:36 +0200 Subject: [PATCH] Fix test_dictionary_dir --- tests/unit/browser/webengine/test_spell.py | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/unit/browser/webengine/test_spell.py b/tests/unit/browser/webengine/test_spell.py index e8ce3cecc..1cc2c5d0f 100644 --- a/tests/unit/browser/webengine/test_spell.py +++ b/tests/unit/browser/webengine/test_spell.py @@ -17,14 +17,14 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Tests for qutebrowser.browser.webengine.spell module.""" - import logging import os +import pytest from PyQt5.QtCore import QLibraryInfo + from qutebrowser.browser.webengine import spell -from qutebrowser.utils import usertypes +from qutebrowser.utils import usertypes, qtutils, standarddir def test_version(message_mock, caplog): @@ -38,10 +38,19 @@ def test_version(message_mock, caplog): assert msg.text == expected -def test_dictionary_dir(monkeypatch): - monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'datapath') - assert spell.dictionary_dir() == os.path.join('datapath', - 'qtwebengine_dictionaries') +@pytest.mark.parametrize('qt_version, old, subdir', [ + ('5.9', True, 'global_datapath'), + ('5.9', False, 'global_datapath'), + ('5.10', True, 'global_datapath'), + ('5.10', False, 'user_datapath'), +]) +def test_dictionary_dir(monkeypatch, qt_version, old, subdir): + monkeypatch.setattr(qtutils, 'qVersion', lambda: qt_version) + monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'global_datapath') + monkeypatch.setattr(standarddir, 'data', lambda: 'user_datapath') + + expected = os.path.join(subdir, 'qtwebengine_dictionaries') + assert spell.dictionary_dir(old=old) == expected def test_local_filename_dictionary_does_not_exist(monkeypatch):