nosetests not working reliably with catkin_make [closed]

asked 2017-05-29 02:47:46 -0600

knxa gravatar image

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:

  1. the first workaround using . devel/setup.bash does not work
  2. unittests in other packages also fails to import the lib mymodule1
  3. 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 then catkin_make run_tests works until the next time I delete the build/devel folders.

What am I missing?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by knxa
close date 2017-11-15 06:57:48.261221