Pytest support for ROS / rostest

I concur that pytest feels “easier” / more natural to use (obviously a subjective point). It certainly is more actively being developed and offers more features through the numerous available plugins. For ROS 2 we are using pytest over nose for a while for these reasons.

The new build tool colcon also invokes Python tests with pytest. Since pytest is capable of running tests written for nose this is usually compatible with exiting tests.

There are three parts to Python unit testing to consider:

  • the API used to write unit tests
  • the tool used to perform the testing of a package
  • the tool used by rostest internally

I think the three parts are fairly independent from each other. E.g. using colcon you can run the tests of a ROS package with pytest even though they use nose / unittest API.

1 Like