catkin_make run_tests - can't import Python code
See original GitHub issueNot sure if this is my fault or a bug. I prepared a test repository with minimal example: https://github.com/ZdenekM/rostest-test-repo. The thing is that there are two packages - one with a custom message and the other with rostest where I would like to use the message. When I run test like this rostest test_package test.test
it succeeds - but it fails when I run catkin_make run_tests
(see whole output below - it seems that messages are generated) with ImportError: No module named my_msgs.msg
. What might be wrong?
Scanning dependencies of target tests
Scanning dependencies of target clean_test_results_test_package
Scanning dependencies of target _my_msgs_generate_messages_check_deps_MyMessage
[ 0%] Built target tests
Removing test result files from '/home/zdenal/test_workspace/build/test_results/test_package'
[ 0%] Built target clean_test_results_test_package
[ 0%] Built target _my_msgs_generate_messages_check_deps_MyMessage
Scanning dependencies of target my_msgs_generate_messages_cpp
Scanning dependencies of target my_msgs_generate_messages_py
Scanning dependencies of target my_msgs_generate_messages_lisp
[ 25%] [ 50%] [ 75%] Generating C++ code from my_msgs/MyMessage.msg
Generating Lisp code from my_msgs/MyMessage.msg
Generating Python from MSG my_msgs/MyMessage
[ 75%] Built target my_msgs_generate_messages_lisp
[100%] Generating Python msg __init__.py for my_msgs
[100%] Built target my_msgs_generate_messages_py
[100%] Built target my_msgs_generate_messages_cpp
Scanning dependencies of target _run_tests_test_package_rostest_test_test.test
-- run_tests.py: execute commands
/opt/ros/indigo/share/rostest/cmake/../../../bin/rostest --pkgdir=/home/zdenal/test_workspace/src/rostest-test-repo/test_package --package=test_package --results-filename test_test.xml --results-base-dir /home/zdenal/test_workspace/build/test_results /home/zdenal/test_workspace/src/rostest-test-repo/test_package/test/test.test
... logging to /home/zdenal/.ros/log/rostest-ZMThinkpad-30945.log
[ROSUNIT] Outputting test results to /home/zdenal/test_workspace/build/test_results/test_package/rostest-test_test.xml
Traceback (most recent call last):
File "/home/zdenal/test_workspace/src/rostest-test-repo/test_package/test/test.py", line 8, in <module>
from my_msgs.msg import MyMessage
ImportError: No module named my_msgs.msg
testtest_package_test ... FAILURE!
FAILURE: test [test_package_test] did not generate test results
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/opt/ros/indigo/lib/python2.7/dist-packages/rostest/runner.py", line 164, in fn
self.assert_(os.path.isfile(test_file), "test [%s] did not generate test results"%test_name)
File "/usr/lib/python2.7/unittest/case.py", line 424, in assertTrue
raise self.failureException(msg)
--------------------------------------------------------------------------------
[ROSTEST]-----------------------------------------------------------------------
[testtest_package_test][failed]
SUMMARY
* RESULT: FAIL
* TESTS: 0
* ERRORS: 0
* FAILURES: 1
ERROR: The following tests failed to run:
* testtest_package_test
Issue Analytics
- State:
- Created 7 years ago
- Comments:31 (13 by maintainers)
Top Results From Across the Web
trigger python rostest with catkin_make test - ROS Answers
I want to trigger a python unit-test trough rostest in the ros-enviroment by calling catkin_make test in the package-root.
Read more >Can't run catkin_make, can't resolve UnicodeDecodeError
It looks like an unicode problem. In very brief summary, you have passed something that is being interpreted as a string of bytes...
Read more >ROS setup tutorial | CLion Documentation - JetBrains
Launch CLion in the sourced environment · Open a ROS project in CLion · Set build paths to the catkin workspace · Work...
Read more >Open Source Q&A Forum - RSS feed - ROS Answers
Can we then execute all tests simply with `catkin_make run_tests`? **Appendix: File ... Next Node fails to import Python package during isolated test...
Read more >Unit Testing - Personal Robotics Lab
Catkin can run C++ unit tests using the googletest library in C++ and the nosetest utility in Python. This page includes instructions for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your detailed answer. The first approach does not work for me but the second does - great! Maybe, it would be nice to document this somewhere.
Please see #986 for a proposed patch which avoid the need for the mentioned workarounds.