I am trying to run a tests file in a Django
project, the app is called jira
and project jiraglean
, test file is tests.py
I run the test with:
jiraglean test jira.tests --settings=core.settings.test
Which causes this error:
File "/Users/pavel/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 86, in
_run_code
File "/Users/pavel/.pyenv/versions/3.8.2/lib/python3.8/multiprocessing/context.py",
line 57, in Manager
exec(code, run_globals)
File "/Users/pavel/Library/Caches/pypoetry/virtualenvs/jiraglean-VXquq6c2-
py3.8/bin/jiraglean", line 2, in <module>
from jiraglue.jiraglue import run
ModuleNotFoundError: No module named 'jiraglean.jiraglean'; 'jiraglean' is not a
package
I am in a poetry virtual env when doing this. Path to project binary is correct /bin/jiraglean
. Test runner instantiates. I just do not understand this error.
Relevant files/folders.
jiraglean
├─ core
│ ├─ management
│ ├─ permissions
│ ├─ settings
│ │ ├─ __init__.py
│ │ ├─ base.py
│ │ ├─ ci.py
│ │ ├─ dev.py
│ │ └─ test.py
│ ├─ __init__.py
│ ├─ api.py
│ ├─ pagination.py
│ ├─ serializers.py
│ ├─ urls.py
│ ├─ utils.py
│ └─ wsgi.py
├─ jira
│ ├─ __init__.py
│ ├─ admin.py
│ ├─ api.py
│ ├─ apps.py
│ ├─ models.py
│ ├─ serializers.py
│ ├─ tests.py
│ └─ views.py
UPDATE:
Project is run at root with following, hence no manage.py
-
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings.dev")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)