-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleNotFoundError python unit test #233
Comments
After a bit more digging, it seems to me that
I think what is happening is that Python finds the module in the source directory when importing |
+1 on this issue. I'll circle-back if I find a solution. |
Probably a good idea hold the 0.4.0 release until this one is solved? Would be nice to have the fix in. |
Hello @Raivias and @sea-bass, thank you both for taking a look! I pushed a commit (forssea-robotics@b1a3abd) that fixes the issue for me. I'm not convinced it is the best solution, but at least it is a work around. The fix installs the parameter module to the source directory, in addition to the build and install locations, if the user explicitly sets |
I can confirm that if I run a a test that includes generated parameters it fails, but if I build with |
@imcelroy I'm worried about that workaround mostly because installing to the source directory will be quite annoying for source control purposes. Not knowing much about the internals... could another workaround be to specifically add to the So in the Python tests, to do But of course, there's probably a better way which requires doing some homework. |
OK I was able to reproduce the test now. Also, turns out that I had approved #207, but I think this actually breaks the install location and we need to revert it. Could someone confirm? -- I made #236 What is described in #233 (comment) is exactly what is happening. Weirdly enough, it seems like modifying
note this is the I think at this point the Python path doesn't even matter because the current folder is the Indeed, if you move that unit test to any other package and run it, the test will actually succeed! Because This might be largely a Python issue we can't easily fix... testing from other packages works, at least? |
One thing that does work is actually to not have an This works great for me... check out this PR? #237 |
Hello,
I am having errors when running
colcon test
for unit tests of python modules that use parameters generated bygenerate_parameter_library
.I have created a simple unit test that reproduces this error using your
example_python
on this branch: bug/python-example-unit-test. It simply imports theminimal_publisher
module.Here are the steps to reproduce the error:
rosdep update
rosdep install --rosdistro humble
colcon build --cmake-args -DBUILD_TESTING=1 -DCMAKE_EXPORT_COMPILE_COMMANDS=On --event-handlers console_direct+ --merge-install
colcon test --merge-install --packages-select generate_parameter_module_example --event-handlers console_cohesion+ log_command+ summary+ --return-code-on-test-failure
The result should give something like the following:
Note: It seems to work if you run
pytest
directly inside thetest/
folder.@christophfroehlich I'm not sure who to tag, but I appreciate any help with this. Thanks!
(possible related issues: #192, #141)
Context:
The text was updated successfully, but these errors were encountered: