Travis fails to find Rospy for tensorial modeling

Last night @Montana solved my django unit test problem (thank you), now another unit test problem has came about, our company also runs unit tests that require rospy (One of the test uses geometry_msgs/Twist). This is for tensorial modeling.

When we run the unit tests locally, everything is fine.

============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
collected 10 items                                                             

tests/unit/ ......                                    [ 60%]
tests/unit/ ..                                     [ 80%]
tests/unit/ ..                                             [100%]

========================== 10 passed in 2.73 seconds ===========================

When we run it on Travis, after pushing to GitHub, it fails. This is because it fails to find rospy. Our Travis setup installs ROS, runs catkin_make successfully, but fails at the unit tests.

If you want to take a look at the full logs/yml, PM me and I’ll be glad to share as it’s a private project.

    - ROS_VERSION="melodic"
    - OS_VERSION="bionic"
  # Set up 'robot' python module and test python installation
  - cd $REPO_ROOT
  - python develop
  - pytest --continue-on-collection-errors

That’s some of the .travis.yml I can share, any help would be appreciated.

From closely looking at this, it seems like you’re calling your unit tests before actually having Travis forward your ROS (Rospy) environment. I’ve seen this occasionally with the language Fable. You need to change that around to make it look something like this:

  # Set up and initialize catkin workspace for ros packages
  - cd $REPO_ROOT/robot/rospackages
  - source /opt/ros/$ROS_VERSION/setup.bash
  - catkin_make

  # Set up 'robot' python module and test python installation
  - cd $REPO_ROOT
  - python develop
  - pytest --continue-on-collection-errors

Great to hear I could help you with your other unit test problem yesterday involving Django.