예제 #1
0
def test_spell_check(known_words):
    source_filenames = [Path(__file__).parents[1] / 'setup.py'] + \
        list((Path(__file__).parents[1] / 'colcon_cmake').glob('**/*.py')) + \
        list((Path(__file__).parents[1] / 'test').glob('**/*.py'))

    for source_filename in sorted(source_filenames):
        print('Spell checking:', source_filename)

    # check all files
    report = Report(known_words)
    spell_check([str(p) for p in source_filenames],
                base_dicts=[SCSPELL_BUILTIN_DICT],
                report_only=report,
                additional_extensions=[('', 'Python')])

    unknown_word_count = len(report.unknown_words)
    assert unknown_word_count == 0, \
        'Found {unknown_word_count} unknown words: '.format_map(locals()) + \
        ', '.join(sorted(report.unknown_words))

    unused_known_words = set(known_words) - report.found_known_words
    unused_known_word_count = len(unused_known_words)
    assert unused_known_word_count == 0, \
        '{unused_known_word_count} words in the word list are not used: ' \
        .format_map(locals()) + ', '.join(sorted(unused_known_words))
예제 #2
0
def test_additional_extensions():
    source_filenames = [
        os.path.join(os.path.dirname(__file__), 'fileidmap', 'inputfile.txt')
    ]
    report = Report(('soem', 'other'))
    result = spell_check(source_filenames, report_only=report)
    assert result is False

    # 'other' was not found in the input
    assert report.found_known_words == {'soem'}
    assert report.unknown_words == {'wrods', 'finially'}