From ce07f8e37c08be06c3d99ce8c29efb4f69f7389f Mon Sep 17 00:00:00 2001 From: SubaruArai <78188579+SubaruArai@users.noreply.github.com> Date: Wed, 6 Sep 2023 05:19:19 +0900 Subject: [PATCH] Update outdated testing documentation (use pytest) (#38143) * 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. --- .gitignore | 1 + .yamllint | 3 +++ CONTRIBUTING.md | 44 ++++++++++++++++++++------------------------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index ad3c46e81b3ac..e01b29e2ce902 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ .DS_STORE *.pyc +.venv/* diff --git a/.yamllint b/.yamllint index 19e2b8f644a75..133185e1fbd51 100644 --- a/.yamllint +++ b/.yamllint @@ -16,3 +16,6 @@ rules: allow-non-breakable-words: true ignore: | rosdep/*.yaml + +ignore: | + .venv diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35bdb38965eec..1a58e4b58444e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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) +