Skip to content

Add instructions for use in ament_python as a tests invoked with colcon #5

@Ryanf55

Description

@Ryanf55

Thanks for putting this package together.

Can you also add documentation for how to use this package as part of a python based ROS package?
Considering it's a python formatter, it would be great to show how to use it in a standard ROS python package.

So far, I've have this. I can format the code with ament_black, but then the test fails. It can't tell why, only the number of failures are reported.

package.xml

<test_depend>ament_black</test_depend>

setup.py

from setuptools import setup

setup(
    ....
    tests_require=['pytest'],
)

test/test_black.py

from ament_black.main import main
import pytest


@pytest.mark.linter
def test_black():
    rc = main()
    assert rc == 0, "Found %d code style errors:"

Results

$ colcon test-result --all --verbose
build/vcgencmd/pytest.xml: 3 tests, 0 errors, 1 failure, 1 skipped
- vcgencmd.test.test_black test_black
  <<< failure message
    AssertionError: Found %d code style errors:
    assert 1 == 0
  >>>

Summary: 3 tests, 0 errors, 1 failure, 1 skipped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions