Skip to content

Commit

Permalink
Update outdated testing documentation (use pytest) (#38143)
Browse files Browse the repository at this point in the history
* Update outdated testing documentation (use pytest)

The CONTRIBUTING.md's "How to submit pull requests" specified nosetests,
which is no longer used. (see: commit id f27dfbf, github pr #36201)
This commit updates the documentation to use pytest instead, and also
encourages the use of a virtual environment.

Config files are also updated to ignore the virtual environment.
  • Loading branch information
SubaruArai authored Sep 5, 2023
1 parent abdfd7d commit ce07f8e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
.DS_STORE
*.pyc
.venv/*
3 changes: 3 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ rules:
allow-non-breakable-words: true
ignore: |
rosdep/*.yaml

ignore: |
.venv
44 changes: 20 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,31 +297,27 @@ How to submit pull requests
When submitting pull requests it is expected that they pass the unit tests for formatting.
The unit tests enforce alphabetization of elements and a consistent formatting to keep merging as clean as possible.

If you want to run the tests before submitting, first install the dependencies. Using `pip` is recommended.
### Unit Testing

```bash
python3 -m pip install -r test/requirements.txt
```
It is recommended to use a virtual environment and pip to install the unit test dependencies.
The test dependencies are listed in tests/requirements.txt.

To run the tests run ``pytest -s test`` in the root of the repository.
These tests require several dependencies that can be installed either from the ROS repositories or via pip (list built based on the content of [test/requirements.txt](https://github.com/ros/rosdistro/blob/master/test/requirements.txt):

| Dependency | Ubuntu package (<=22.04)| Pip package |
| :------------: | --------------------------------- | -------------- |
| catkin_pkg | python3-catkin-pkg | catkin-pkg |
| github | python3-github | PyGithub |
| pytest | python3-pytest | pytest |
| yaml | python3-yaml | PyYAML |
| rosdep | python3-rosdep | rosdep |
| rosdistro | python3-rosdistro | rosdistro |
| ros_buildfarm | python3-ros-buildfarm | ros-buildfarm |
| unidiff | python3-unidiff (Zesty and higher) | unidiff |
| yamllint | yamllint | yamllint |

There is a tool [scripts/check_rosdep](./scripts/check_rosdep.py) which will check most formatting errors such as alphabetization and correct formatting.
It is recommended to run it before submitting your contribution.

For example, to check a change to `rosdep/base.yaml`:
```bash
python3 scripts/check_rosdep.py rosdep/base.yaml
# create the virtual environment
python3 -m venv .venv
# "activate" the virtual environment
# this will let pip install dependencies into the virtual environment
# use activate.zsh if you use zsh, activate.fish if you use fish, etc.
source .venv/bin/activate
# install the dependencies
pip3 install -r test/requirements.txt
# run the tests!
pytest
```

It is highly recommended to run the unit tests before submitting a pull request.
(the CI system will run them anyways, but it will save you time)

0 comments on commit ce07f8e

Please sign in to comment.