nosetests not working reliably with catkin_make [closed]
I have a simple catkin package with a python module mymodule1.
The unittests work perfectly when running nosetests
directly or when running
catkin_make_isolated --make-args run_tests
But when running:
catkin_make run_tests
the testing fails with the error: ImportError: No module named mymodule1
In my workspace src folder I have this structure:
package_1/
CMakeLists.txt
package.xml
setup.py
python/
mymodule1/
a.py
test/
test_a.py
package_2/
...
And test_a.py says:
from mymodule1.a import *
I believe the python path is ok:
$ echo $PYTHONPATH
/home/kn/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages
My CMakeLists.txt for package_1 can be boiled down to:
catkin_python_setup()
catkin_add_nosetests(python/mymodule1/test
DEPENDENCIES ${${PROJECT_NAME}_EXPORTED_TARGETS})
And the file package_1/setup.py contains:
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['mymodule1'],
package_dir={'': 'python'}
)
setup(**d)
At first I was suspecting the "Limitations of catkin_make" problem described here
but for several reasons I am not convinced:
- the first workaround using
. devel/setup.bash
does not work - unittests in other packages also fails to import the lib mymodule1
- sometimes the
catkin_make run_tests
works. I am not 100% certain about the exact pattern, but it seems like if I touch a CMakeLists.txt file thencatkin_make run_tests
works until the next time I delete the build/devel folders.
What am I missing?