My first contribution

Hi,
I choose from tickets this one but I can’t reproduce the error,
I studied run tests but it make another error:
Traceback (most recent call last):
File “./runtests.py”, line 16, in
import django
File “/usr/local/lib/python3.8/dist-packages/django/init.py”, line 1, in
from django.utils.version import get_version
ModuleNotFoundError: No module named ‘django.utils’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “./runtests.py”, line 18, in
raise RuntimeError(
RuntimeError: Django module not found, reference tests/README.rst for instructions.
Error in sys.excepthook:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/apport_python_hook.py”, line 72, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File “/usr/lib/python3/dist-packages/apport/init.py”, line 5, in
from apport.report import Report
File “/usr/lib/python3/dist-packages/apport/report.py”, line 32, in
import apport.fileutils
File “/usr/lib/python3/dist-packages/apport/fileutils.py”, line 12, in
import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
File “/usr/lib/python3/dist-packages/requests_unixsocket/init.py”, line 4, in
from .adapters import UnixAdapter
File “/usr/lib/python3/dist-packages/requests_unixsocket/adapters.py”, line 3, in
from requests.adapters import HTTPAdapter
ModuleNotFoundError: No module named ‘requests.adapters’

Original exception was:
Traceback (most recent call last):
File “./runtests.py”, line 16, in
import django
File “/usr/local/lib/python3.8/dist-packages/django/init.py”, line 1, in
from django.utils.version import get_version
ModuleNotFoundError: No module named ‘django.utils’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “./runtests.py”, line 18, in
raise RuntimeError(
RuntimeError: Django module not found, reference tests/README.rst for instructions.

I didn’t see any other instruction to run test in documentation.
Thanks.

Hi @mam — It looks like (?) you haven’t set up you’re virtual environment properly.

Have a look at this part of the Contributing Guide, which had a good walk-through on running the test suite: Unit Tests | Django Documentation | Django

I do exactly the same as mentioned in docs

$ git clone https://github.com/YourGitHubName/django.git django-repo
$ cd django-repo/tests
$ python -m pip install -e …
$ python -m pip install -r requirements/py3.txt
$ ./runtests.py

1 Like

OK, but…

All I can suggest is open a REPL, and see if you can import django:

% python
Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(4, 1, 0, 'alpha', 0)

Check this is right. If you’re in the tests dir .. will give you the repo root (you’ve put ... — three dots there…?)

Thank you @carltongibson
I check your command and works exactly fine.
I check it in other directories and see that Django is installed in my machine and It doesn’t installed correctly so the error was for that So I build a fresh python environment to test it.

No, it’s ..