I have a python project where I cannot run tests on a class in a subdirectory from the command line. It works in Pycharm, but not from the command line. I simplified it to the following:
/utils
__init__.py
util.py
/tests
test.py
Where util.py looks like:
class UtilClass:
def __init__(self):
print(" in __init__ ")
And utils/__init__.py is:
from .util import (
UtilClass
)
And test.py just tries to call it:
from utils import UtilClass
x = UtilClass()
When I run (from the top level directory): % python tests/test.py is says ModuleNotFoundError: No module named 'utils'. Do I need to do something with the path to include utils? Or some sort of init.py in the top level dir?