Unit Tests Not Importing Project Modules (python)
My code structure is: + project | + - - project_code | | __init__.py | \ main.py | + - - test | __init__.py \ test_main.py In my test_main.py I have: import
Solution 1:
Put an empty __init__.py in your project folder to make it a package and then either change your code to
import unittest
from project.project_code.mainimportMainClassor do it the relative way with
import unittest
from ..project_code.mainimportMainClassYour test_main in package test, will not find a module or package named project_code, because it expects it to be inside the test package.
Post a Comment for "Unit Tests Not Importing Project Modules (python)"