I know this has been asked a lot of times, been looking at it for the last two hours and still can't figure it out. Would be very grateful for a solution to my actual problem rather than a link to someone else problem if possible.
Here goes...
/src
/moduleA
__init__.py
messages.py
/tests
testA.py
messages.py
def get_messages(paramA):
if paramA:
return "A"
else:
return "B"
testA.py
import unittest
from moduleA import messages
My unit test will simply check whether A
or B
is returned from the get_messages(...)
function.
As I understand it, moduleA
is a module as it has an __init__.py
file. VSCode does not complain about the from moduleA import messages
line in my test however when I try to execute testA.py
I get the following error message...
ImportError: No module named moduleA
.
Also tried running it with python -m
Would be very grateful if someone can tell me what I'm doing wrong. I can change my file structure around if that would help. Perhaps the examples I've been reading are for Python 3 and I'm using 2.7?
Thanks.