File: test_spell_check.py

package info (click to toggle)
ros2-colcon-library-path 0.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: python: 145; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright 2016-2018 Dirk Thomas
# Licensed under the Apache License, Version 2.0

from pathlib import Path

from pylint.lint import Run
import pytest


spell_check_words_path = Path(__file__).parent / 'spell_check.words'


def test_spell_check():

    try:
        import enchant  # noqa: F401
    except ImportError:  # pragma: no cover
        pytest.skip(
            "Skipping spell checking tests since 'enchant' was not found")

    try:
        Run([
            '--disable=all',
            '--enable=spelling',
            '--spelling-dict=en_US',
            '--ignore-comments=no',
            '--spelling-private-dict-file=' +
            str(spell_check_words_path),
            str(Path(__file__).parents[1] / 'colcon_library_path'),
        ] + [
            str(p) for p in
            (Path(__file__).parents[1] / 'test').glob('**/*.py')
        ])
    except SystemExit as e:
        assert not e.code, 'Some spell checking errors'
    else:
        assert False, 'The pylint API is supposed to raise a SystemExit'


def test_spell_check_word_list():
    with spell_check_words_path.open('r') as h:
        lines = h.read().splitlines()
    assert lines == sorted(lines), \
        'The word list should be ordered alphabetically'