Skip to content

Commit

Permalink
Add pytest markers, junit suite name (#64)
Browse files Browse the repository at this point in the history
With these markers present, pytest can be used to filter for or against
"linter" or "flake8", as is possible in other ROS packages.

Additionally, by moving the imports for flake8 into the test body, tests
can be executed without flake8 installed (as is a common practice in
system packaging).
  • Loading branch information
cottsay authored Feb 28, 2024
1 parent 97b3be2 commit 4e587a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ zip_safe = false
# test
# test.*

# [tool:pytest]
[tool:pytest]
# filterwarnings =
# error
# ignore:the imp module is deprecated in favour of importlib.*:DeprecationWarning
# ignore:the imp module is deprecated in favour of importlib.*:PendingDeprecationWarning
# junit_suite_name = rosdoc2
junit_suite_name = rosdoc2
markers =
flake8
linter

[options.entry_points]
rosdoc2.verbs =
Expand Down
12 changes: 7 additions & 5 deletions test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
import os
import sys

from flake8 import LOG
from flake8.api.legacy import get_style_guide
import pytest


# suppress warning messages from flake8
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():
style_guide = get_style_guide(
extend_ignore=['D100', 'D104', 'W503'],
show_source=True,
Expand Down

0 comments on commit 4e587a5

Please sign in to comment.