Fix test_dictionary_dir

This commit is contained in:
Florian Bruhin 2018-06-21 01:40:36 +02:00
parent 1000a1eac2
commit 4887385bdd

View File

@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Tests for qutebrowser.browser.webengine.spell module."""
import logging import logging
import os import os
import pytest
from PyQt5.QtCore import QLibraryInfo from PyQt5.QtCore import QLibraryInfo
from qutebrowser.browser.webengine import spell from qutebrowser.browser.webengine import spell
from qutebrowser.utils import usertypes from qutebrowser.utils import usertypes, qtutils, standarddir
def test_version(message_mock, caplog): def test_version(message_mock, caplog):
@ -38,10 +38,19 @@ def test_version(message_mock, caplog):
assert msg.text == expected assert msg.text == expected
def test_dictionary_dir(monkeypatch): @pytest.mark.parametrize('qt_version, old, subdir', [
monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'datapath') ('5.9', True, 'global_datapath'),
assert spell.dictionary_dir() == os.path.join('datapath', ('5.9', False, 'global_datapath'),
'qtwebengine_dictionaries') ('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): def test_local_filename_dictionary_does_not_exist(monkeypatch):