Exemple #1
0
def test_local_filename_dictionary_installed(tmpdir, monkeypatch):
    """Tests retrieving local filename when the dict installed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    for lang_file in ['en-US-11-0.bdic', 'en-US-7-1.bdic', 'pl-PL-3-0.bdic']:
        (tmpdir / lang_file).ensure()
    assert spell.local_filename('en-US') == 'en-US-11-0'
    assert spell.local_filename('pl-PL') == 'pl-PL-3-0'
def test_local_filename_dictionary_installed(tmpdir, monkeypatch):
    """Tests retrieving local filename when the dict installed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    for lang_file in ['en-US-11-0.bdic', 'en-US-7-1.bdic', 'pl-PL-3-0.bdic']:
        (tmpdir / lang_file).ensure()
    assert spell.local_filename('en-US') == 'en-US-11-0.bdic'
    assert spell.local_filename('pl-PL') == 'pl-PL-3-0.bdic'
Exemple #3
0
 def _find_installed(self, code):
     local_filename = spell.local_filename(code)
     if not local_filename:
         message.warning(
             "Language {} is not installed - see scripts/dictcli.py "
             "in qutebrowser's sources".format(code))
     return local_filename
 def _find_installed(self, code):
     local_filename = spell.local_filename(code)
     if not local_filename:
         message.warning(
             "Language {} is not installed - see scripts/dictcli.py "
             "in qutebrowser's sources".format(code))
     return local_filename
Exemple #5
0
def test_local_filename_installed_malformed(tmpdir, monkeypatch, caplog):
    """Tests retrieving local filename when the dict installed.

    In this usecase, another existing file is malformed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    for lang_file in ['en-US-11-0.bdic', 'en-US-7-1.bdic', 'en-US.bdic']:
        (tmpdir / lang_file).ensure()
    with caplog.at_level(logging.WARNING):
        assert spell.local_filename('en-US') == 'en-US-11-0'
def test_local_filename_installed_malformed(tmpdir, monkeypatch, caplog):
    """Tests retrieving local filename when the dict installed.

    In this usecase, another existing file is malformed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    for lang_file in ['en-US-11-0.bdic', 'en-US-7-1.bdic', 'en-US.bdic']:
        (tmpdir / lang_file).ensure()
    with caplog.at_level(logging.WARNING):
        assert spell.local_filename('en-US') == 'en-US-11-0.bdic'
def _set_dictionary_language(profile, warn=True):
    filenames = []
    for code in config.val.spellcheck.languages or []:
        local_filename = spell.local_filename(code)
        if not local_filename:
            if warn:
                message.warning(
                    "Language {} is not installed - see scripts/dictcli.py "
                    "in qutebrowser's sources".format(code))
            continue

        filenames.append(local_filename)

    log.config.debug("Found dicts: {}".format(filenames))
    profile.setSpellCheckLanguages(filenames)
def _set_dictionary_language(profile, warn=True):
    filenames = []
    for code in config.val.spellcheck.languages or []:
        local_filename = spell.local_filename(code)
        if not local_filename:
            if warn:
                message.warning(
                    "Language {} is not installed - see scripts/dictcli.py "
                    "in qutebrowser's sources".format(code))
            continue

        filenames.append(local_filename)

    log.config.debug("Found dicts: {}".format(filenames))
    profile.setSpellCheckLanguages(filenames)
Exemple #9
0
    def set_dictionary_language(self, warn=True):
        """Load the given dictionaries."""
        filenames = []
        for code in config.val.spellcheck.languages or []:
            local_filename = spell.local_filename(code)
            if not local_filename:
                if warn:
                    message.warning("Language {} is not installed - see "
                                    "scripts/dictcli.py in qutebrowser's "
                                    "sources".format(code))
                continue

            filenames.append(local_filename)

        log.config.debug("Found dicts: {}".format(filenames))
        self._profile.setSpellCheckLanguages(filenames)
    def set_dictionary_language(self, warn=True):
        """Load the given dictionaries."""
        filenames = []
        for code in config.val.spellcheck.languages or []:
            local_filename = spell.local_filename(code)
            if not local_filename:
                if warn:
                    message.warning("Language {} is not installed - see "
                                    "scripts/dictcli.py in qutebrowser's "
                                    "sources".format(code))
                continue

            filenames.append(local_filename)

        log.config.debug("Found dicts: {}".format(filenames))
        self._profile.setSpellCheckLanguages(filenames)
        self._profile.setSpellCheckEnabled(bool(filenames))
    def set_dictionary_language(self):
        """Load the given dictionaries."""
        filenames = []
        for code in config.val.spellcheck.languages or []:
            local_filename = spell.local_filename(code)
            if not local_filename:
                if not self._profile.isOffTheRecord():
                    message.warning("Language {} is not installed - see "
                                    "scripts/dictcli.py in qutebrowser's "
                                    "sources".format(code))
                continue

            filenames.append(os.path.splitext(local_filename)[0])

        log.config.debug("Found dicts: {}".format(filenames))
        self._profile.setSpellCheckLanguages(filenames)
        self._profile.setSpellCheckEnabled(bool(filenames))
Exemple #12
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.fullmatch(tag)
    if not match:
        return None

    event = match.group('event')
    dictionary = match.group('dict')
    has_dict = spell.local_filename(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
Exemple #13
0
 def __attrs_post_init__(self):
     if self.local_filename is None:
         self.local_filename = spell.local_filename(self.code)
Exemple #14
0
def test_local_filename_dictionary_does_not_exist(tmpdir, monkeypatch):
    monkeypatch.setattr(spell, 'dictionary_dir',
                        lambda: '/some-non-existing-dir')
    assert not spell.local_filename('en-US')
Exemple #15
0
def test_local_filename_dictionary_not_installed(tmpdir, monkeypatch):
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    assert not spell.local_filename('en-US')
Exemple #16
0
def test_local_filename_dictionary_does_not_exist(tmpdir, monkeypatch):
    monkeypatch.setattr(
        spell, 'dictionary_dir', lambda: '/some-non-existing-dir')
    assert not spell.local_filename('en-US')
Exemple #17
0
 def __attrs_post_init__(self):
     if self.local_filename is None:
         self.local_filename = spell.local_filename(self.code)
def test_local_filename_not_installed_malformed(tmpdir, monkeypatch, caplog):
    """Tests retrieving local filename when the only file is malformed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    (tmpdir / 'en-US.bdic').ensure()
    with caplog.at_level(logging.WARNING):
        assert not spell.local_filename('en-US')
Exemple #19
0
def test_local_filename_dictionary_not_installed(tmpdir, monkeypatch):
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    assert not spell.local_filename('en-US')
def test_local_filename_dictionary_not_installed(tmpdir, monkeypatch):
    """Tests retrieving local filename when the dict not installed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    assert not spell.local_filename('en-US')
def test_local_filename_dictionary_does_not_exist(monkeypatch):
    """Tests retrieving local filename when the dir doesn't exits."""
    monkeypatch.setattr(spell, 'dictionary_dir',
                        lambda: '/some-non-existing-dir')
    assert not spell.local_filename('en-US')
Exemple #22
0
def test_local_filename_dictionary_does_not_exist(monkeypatch):
    """Tests retrieving local filename when the dir doesn't exits."""
    monkeypatch.setattr(
        spell, 'dictionary_dir', lambda: '/some-non-existing-dir')
    assert not spell.local_filename('en-US')
Exemple #23
0
def test_local_filename_dictionary_not_installed(tmpdir, monkeypatch):
    """Tests retrieving local filename when the dict not installed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    assert not spell.local_filename('en-US')
Exemple #24
0
def test_local_filename_not_installed_malformed(tmpdir, monkeypatch, caplog):
    """Tests retrieving local filename when the only file is malformed."""
    monkeypatch.setattr(spell, 'dictionary_dir', lambda: str(tmpdir))
    (tmpdir / 'en-US.bdic').ensure()
    with caplog.at_level(logging.WARNING):
        assert not spell.local_filename('en-US')