'Bazel test `ImportError` Relative Import

When I run bazel test :all -- --test_output=all I get:

ImportError: attempted relative import with no known parent package

I have tried doing a relative import like so:

from .pose import Pose

I then tried using the absolute import, using the directory name which does contain a __init__.py file:

from pose_format.pose import Pose

But then I get:

ModuleNotFoundError: No module named 'pose_format'


Running the second configuration using pytest (built in PyCharm) works, while the first one doesn't.

Is there a way to let bezel know what is the relative module structure?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source