pytest with Flask can't locate module [duplicate] pytest with Flask can't locate module [duplicate] flask flask

pytest with Flask can't locate module [duplicate]


You might need to run pytest as a module in python (which adds the current directory to sys.path). I remember having a similar situation and this resolved it for me:

python -m pytest -vv

Source: https://docs.pytest.org/en/latest/usage.html#calling-pytest-through-python-m-pytest

You can invoke testing through the Python interpreter from the command line:

python -m pytest [...]This is almost equivalent to invoking the command line script pytest [...] directly, except that calling via python will also add the current directory to sys.path.