I have a very basic question about Python and unittest.
I have a directory structure like this.
Project
|
|-lib
|
|-__init__.py
|-class.py
|
|-tests
|
|-__init__.py
|-test_class.py
Now this is my content of test_class.py. If I import the lib.class from the root folder it's working fine. But if I import the file from somewhere else it's not working.
import unittest
from lib.class import Class
class TestClass(unittest.TestCase):
def testClass(self):
// do some test
def main():
unittest.main()
if __name__ == '__main__':
main()
When I run the test I got this error
Traceback (most recent call last):
File "tests/test_class.py", line 2, in
from lib.class import Class
ImportError: No module named lib.class
Not sure how do I import the file from another folder that's not the root folder.