Exemplo n.º 1
0
 def _find_installed(self, code):
     installed_file = spell.installed_file(code)
     if not installed_file:
         message.warning(
             "Language {} is not installed - see scripts/install_dict.py "
             "in qutebrowser's sources".format(code))
     return installed_file
Exemplo n.º 2
0
def _get_dictionary_tag(tag):
    """Handle tags like must_have_dict=en-US for BDD tests."""
    dict_re = re.compile(r"""
        (?P<event>must_have_dict|cannot_have_dict)=(?P<dict>[a-z]{2}-[A-Z]{2})
    """, re.VERBOSE)

    match = dict_re.match(tag)
    if not match:
        return None

    event = match.group('event')
    dictionary = match.group('dict')
    has_dict = spell.installed_file(dictionary) is not None
    if event == 'must_have_dict':
        return pytest.mark.skipif(not has_dict, reason=tag)
    elif event == 'cannot_have_dict':
        return pytest.mark.skipif(has_dict, reason=tag)
    else:
        return None
Exemplo n.º 3
0
def test_installed_file_dictionary_installed(tmpdir, monkeypatch):
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    for lang_file in ['en-US-7-1.bdic', 'pl-PL-3-0.bdic']:
        (tmpdir / lang_file).ensure()
    assert spell.installed_file('en-US') == 'en-US-7-1'
    assert spell.installed_file('pl-PL') == 'pl-PL-3-0'
Exemplo n.º 4
0
def test_installed_file_dictionary_not_installed(tmpdir, monkeypatch):
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    assert not spell.installed_file('en-US')
Exemplo n.º 5
0
def test_installed_file_dictionary_does_not_exist(tmpdir, monkeypatch):
    monkeypatch.setattr(spell, 'dictionary_dir',
                        lambda: '/some-non-existing-dir')
    assert not spell.installed_file('en-US')