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.

pytest
============================= 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/branch_name_test.py ......                                    [ 60%]
tests/unit/drive_controls_test.py ..                                     [ 80%]
tests/unit/import_test.py ..                                             [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.

 script
    - TEENSYDUINO_VERSION="152"
    - ROS_PYTHON_VERSION="3.6"
    - ROS_VERSION="melodic"
    - OS_VERSION="bionic"
  
script:
  # Set up 'robot' python module and test python installation
  - cd $REPO_ROOT
  - python setup.py 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:

script:
  # 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 setup.py develop
  - pytest --continue-on-collection-errors

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

2 Likes