Python imports fail when using unittest module

16 views Asked by At

I have the following directory structure:

project/
    lambda_functions/
        user_plot
            user_plot_lib/
            ├── __init__.py
            ├── a.py
            └── b.py
            user_plot_client.py
          
    test/
        unit/
           ├── __init__.py
           ├── test_user_plot.py

Inside of my user_plot_client.py I have imports like so:

from user_plot_lib.a import test_function

I can successfully run code from the user_plot_client.py .

In test_user_plot.py I have the following

from lambda_functions.user_plot.user_plot_client import main

class TestUserPlot(unittest.Testcase):
  def test_main():
      pass

I get the following import error

from user_plot_lib.a import test_function 
ModuleNotFoundError: No module named user_plot_lib

I know it's something to do with the Python path, but I'm not having any luck getting it added. Any better way to structure this so that I don't have to mess with the python path?

0

There are 0 answers