Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markers to linter tests, move linter imports #576

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ filterwarnings =
# Suppress resource warnings pending investigation
always::ResourceWarning
junit_suite_name = colcon-core
markers =
flake8
linter
python_classes = !TestFailure

[options.entry_points]
Expand Down
1 change: 1 addition & 0 deletions test/spell_check.words
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ junit
levelname
libexec
lineno
linter
linux
lstrip
mkdtemp
Expand Down
3 changes: 3 additions & 0 deletions test/test_copyright_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from pathlib import Path
import sys

import pytest


@pytest.mark.linter
def test_copyright_license():
missing = check_files([
Path(__file__).parents[1],
Expand Down
15 changes: 8 additions & 7 deletions test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
from pathlib import Path
import sys

from flake8 import LOG
from flake8.api.legacy import get_style_guide
from pydocstyle.utils import log
import pytest


# avoid debug / info / warning messages from flake8 internals
LOG.setLevel(logging.ERROR)
@pytest.mark.flake8
@pytest.mark.linter
def test_flake8():
from flake8.api.legacy import get_style_guide

# avoid debug / info / warning messages from flake8 internals
logging.getLogger('flake8').setLevel(logging.ERROR)

def test_flake8():
# for some reason the pydocstyle logger changes to an effective level of 1
# set higher level to prevent the output to be flooded with debug messages
log.setLevel(logging.WARNING)
logging.getLogger('pydocstyle').setLevel(logging.WARNING)

style_guide = get_style_guide(
extend_ignore=['D100', 'D104'],
Expand Down
11 changes: 7 additions & 4 deletions test/test_spell_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
from pathlib import Path

import pytest
from scspell import Report
from scspell import SCSPELL_BUILTIN_DICT
from scspell import spell_check


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

Expand All @@ -18,7 +14,12 @@ def known_words():
return spell_check_words_path.read_text().splitlines()


@pytest.mark.linter
def test_spell_check(known_words):
from scspell import Report
from scspell import SCSPELL_BUILTIN_DICT
from scspell import spell_check

source_filenames = [
Path(__file__).parents[1] / 'bin' / 'colcon',
Path(__file__).parents[1] / 'setup.py'] + \
Expand Down Expand Up @@ -46,11 +47,13 @@ def test_spell_check(known_words):
', '.join(sorted(unused_known_words))


@pytest.mark.linter
def test_spell_check_word_list_order(known_words):
assert known_words == sorted(known_words), \
'The word list should be ordered alphabetically'


@pytest.mark.linter
def test_spell_check_word_list_duplicates(known_words):
assert len(known_words) == len(set(known_words)), \
'The word list should not contain duplicates'