1. The environment
I am working in Windows 10 with Anaconda/Spyder tools. I have a python project organized as follow.
folder_project
test_all.py
folder_utils
__init__.py
function1.py
folder_tests
__init__.py
test_function1.py
The init.py files are empty files. Basic idea for implementing code coverage of my code (maybe methodology can be improved) is that I will have:
test_function1.py will contain one function per test:
def test_001(): ...
test_all.py file will call all functions for all test_functionXXX.py files
In Spyder, I have taken care to add in PYTHONPATH the folder_project.
2. The problem
I encounter error in importing the folder_tests package...
I have in test_all.py
import folder_tests.test_function1
def main():
# Testing function1
test_function1.test001()
And I get following error:
ModuleNotFoundError: No module named 'folder_tests.test_function1'
If I only do
import folder_tests
I have no error message, but then I can do nothing with that...
If I change the import statement in
from folder_tests import test_function1
I get following error:
ImportError: cannot import name 'test_function1' from 'folder_tests'
Please, any idea how I could correct that?
I thank you in advance for your help!
Bests,
Pierrot
The origin of the error doesn't seem related to python, but spyder. I stopped and re-launched spyder, it didn't work, I simplified name of files, and it worked, and I then re-used the previous file names, and it still works... Kind of a headache here...
Sorry for the bother.
Bests,
Pierrot