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 instructions for use in ament_python as a tests invoked with colcon #5

Open
Ryanf55 opened this issue Apr 22, 2023 · 0 comments
Open

Comments

@Ryanf55
Copy link

Ryanf55 commented Apr 22, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant