Error/Failure in Django local clone steup

Hi everyone :slight_smile:
I cloned the Django’s development version in my local directory as per the https://docs.djangoproject.com/en/5.1/intro/contributing/.
I follow all steps and reach to runtests.py it runs the entire test suite and gives a report as follows:

Ran 17939 tests in 86.814s
FAILED (failures=10, errors=3, skipped=1373, expected failures=5)
Destroying test database for alias 'default'...

Main Issues Found:

  • XGetText Issues (3 errors)
  • Migration Command Issues (7 failures)
  • Admin Scripts Issues

what should I do next? Should I setup it again from scratch, or can I begin my work, or is there any step I can take like [debug]

please help…

Some details:

  • My Python version: 3.12.5
  • my os: Windows 11
  • I pass this test: python runtests.py model_inheritance
  • here is pip list:
    aiohappyeyeballs 2.4.6 aiohttp 3.11.13 aiosignal 1.3.2 aiosmtpd 1.4.6 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 asgiref 3.8.1 atpublic 5.1 attrs 25.1.0 bcrypt 4.3.0 black 25.1.0 certifi 2025.1.31 cffi 1.17.1 charset-normalizer 3.4.1 click 8.1.8 colorama 0.4.6 Django 6.0.dev20250303103700 D:\Django\django docutils 0.21.2 frozenlist 1.5.0 geoip2 5.0.1 h11 0.14.0 idna 3.10 Jinja2 3.1.5 MarkupSafe 3.0.2 maxminddb 2.6.3 multidict 6.1.0 mypy-extensions 1.0.0 numpy 2.2.3 outcome 1.3.0.post0 packaging 24.2 pathspec 0.12.1 pillow 11.1.0 pip 25.0.1 platformdirs 4.3.6 propcache 0.3.0 pycparser 2.22 pymemcache 4.0.0 PySocks 1.7.1 PyYAML 6.0.2 redis 5.2.1 requests 2.32.3 selenium 4.29.0 sniffio 1.3.1 sortedcontainers 2.4.0 sqlparse 0.5.3 tblib 3.0.0 trio 0.29.0 trio-websocket 0.12.2 typing_extensions 4.12.2 tzdata 2025.1 urllib3 2.3.0 websocket-client 1.8.0 wsproto 1.2.0 yarl 1.18.3
(djangodev) PS D:\Django\django\tests> py runtests.py
Testing against Django installed in 'D:\Django\django\django' with up to 12 processes
Found 17941 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'other'...
Cloning test database for alias 'other'...
Cloning test database for alias 'other'...
Cloning test database for alias 'other'...
Cloning test database for alias 'other'...
System check identified no issues (17 silenced).
s.s.sssss.ssssssss......................................................................................................................................................................................s....s...................s...............................................................................x................................................s....sss.........................................................................................................................................................................................s..............................................sss........................................................................................................................F....F.............................................F.............................................................................................sss.....................s...s..........................................................................................................................................................................................................................................................................................................................................................................ss.................................................................................................................................................................................................................................................Exception in thread Thread-40 (thread_func):
Traceback (most recent call last):
  File "D:\Django\django\django\db\backends\utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Django\django\django\db\backends\sqlite3\base.py", line 360, in execute
    return super().execute(query, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such table: test_utils_car

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(i18n.test_extraction.LocationCommentsTests.test_add_location_file)
makemessages --add-location=file
----------------------------------------------------------------------

    self.process_files(file_list)
    ^^^^^^^^^^^^^^^^^
  File "D:\Django\django\django\core\management\commands\makemessages.py", line 586, in process_files
    self.process_locale_dir(locale_dir, files)
    ^^^^^^^^^^^^^^^^^
  File "D:\Django\django\django\core\management\commands\makemessages.py", line 667, in process_locale_dir
    raise CommandError(
    ^^^^^^^^^^^^^^^^^
django.core.management.base.CommandError: errors happened while running xgettext on .\__init__.py
.\ignore_dir\ignored.html.py
.\media_root\media_ignored.html.py
.\static\static_ignored.html.py
.\templates\empty.html.py
.\templates\subdir\ignored.html.py
.\templates\test.html.py
.\templates\xxx_ignored.html.py
xgettext: option '--add-location' doesn't allow an argument
Try 'xgettext --help' for more information.


======================================================================
ERROR: test_add_location_full (i18n.test_extraction.LocationCommentsTests.test_add_location_full)
makemessages --add-location=full
----------------------------------------------------------------------
  
django.core.management.base.CommandError: errors happened while running xgettext on .\__init__.py
.\ignore_dir\ignored.html.py
.\media_root\media_ignored.html.py
.\static\static_ignored.html.py
.\templates\empty.html.py
.\templates\subdir\ignored.html.py
.\templates\test.html.py
.\templates\xxx_ignored.html.py
xgettext: option '--add-location' doesn't allow an argument
Try 'xgettext --help' for more information.


======================================================================
ERROR: test_add_location_never (i18n.test_extraction.LocationCommentsTests.test_add_location_never)
makemessages --add-location=never
----------------------------------------------------------------------

  File "D:\Django\django\django\core\management\commands\makemessages.py", line 667, in process_locale_dir
    raise CommandError(
    ^^^^^^^^^^^^^^^^^
django.core.management.base.CommandError: errors happened while running xgettext on .\__init__.py
.\ignore_dir\ignored.html.py
.\media_root\media_ignored.html.py
.\static\static_ignored.html.py
.\templates\empty.html.py
.\templates\subdir\ignored.html.py
.\templates\test.html.py
.\templates\xxx_ignored.html.py
xgettext: option '--add-location' doesn't allow an argument
Try 'xgettext --help' for more information.


======================================================================
FAIL: test_setup_environ (admin_scripts.tests.DjangoAdminSettingsDirectory.test_setup_environ)
directory: startapp creates the correct directory
----------------------------------------------------------------------

  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: 'name = "settings_test"' not found in "from django.apps import AppConfig\n\n\nclass SettingsTestConfig(AppConfig):\n    default_auto_field = 'django.db.models.BigAutoField'\n    name = 'settings_test'\n"

======================================================================
FAIL: test_startapp_unicode_name (admin_scripts.tests.DjangoAdminSettingsDirectory.test_startapp_unicode_name)
startapp creates the correct directory with Unicode characters.

  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: 'name = "こんにちは"' not found in "from django.apps import AppConfig\n\n\nclass こんにちはConfig(AppConfig):\n    default_auto_field = 'django.db.models.BigAutoField'\n    name = 'こんにちは'\n"

======================================================================
FAIL: test_template (admin_scripts.tests.StartApp.test_template)
----------------------------------------------------------------------

  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: 'default_auto_field = "django.db.models.BigAutoField"' not found in "from django.apps import AppConfig\n\n\nclass NewAppConfig(AppConfig):\n    default_auto_field = 'django.db.models.BigAutoField'\n    name = 'new_app'\n"

======================================================================
FAIL: test_no_write_access (i18n.test_compilation.PoFileTests.test_no_write_access)
----------------------------------------------------------------------

  File "C:\Python312\Lib\unittest\case.py", line 200, in _raiseFailure
    raise self.test_case.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: CommandError not raised

======================================================================
FAIL: test_optimization (migrations.test_commands.OptimizeMigrationTests.test_optimization)
----------------------------------------------------------------------

  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: '("bool", models.BooleanField' not found in "# Generated by Django 6.0.dev20250303103700 on 2025-03-03 19:10\n\nfrom django.db import migrations,

======================================================================
FAIL: test_optimization_no_verbosity (migrations.test_commands.OptimizeMigrationTests.test_optimization_no_verbosity)
----------------------------------------------------------------------

  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: '("bool", models.BooleanField' not found in "# Generated by Django 6.0.dev20250303103700 on 2025-03-03 19:10\n\nfrom django.db import migrations, 
======================================================================
FAIL: test_squashmigrations_valid_start (migrations.test_commands.SquashMigrationsTests.test_squashmigrations_valid_start)
squashmigrations accepts a starting migration.
----------------------------------------------------------------------
Traceback (most recent call last):
 
  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: '        ("migrations", "0001_initial")' not found in "# Generated by Django 6.0.dev20250303103700 on 2025-03-03 19:10\n\nimport django.db.models.deletion\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):
======================================================================
FAIL: test_makemigrations_default_merge_name (migrations.test_commands.MakeMigrationsTests.test_makemigrations_default_merge_name)
----------------------------------------------------------------------
Traceback (most recent call last):

  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: '("migrations", "0002_conflicting_second")' not found in "# Generated by Django 6.0.dev20250303103700 on 2025-03-03 19:10\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('migrations', '0002_conflicting_second'),\n        ('migrations', '0002_second'),\n    ]\n\n    operations = [\n    ]\n"

======================================================================
FAIL: test_makemigrations_empty_migration (migrations.test_commands.MakeMigrationsTests.test_makemigrations_empty_migration)
makemigrations properly constructs an empty migration.
----------------------------------------------------------------------
Traceback (most recent call last):
  
  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: 'dependencies=[]' not found in '#GeneratedbyDjango6.0.dev20250303103700on2025-03-0319:10\n\nfromdjango.dbimportmigrations\n\n\nclassMigration(migrations.Migration):\n\ndependencies=[\n]\n\noperations=[\n]\n'

======================================================================
FAIL: test_makemigrations_with_custom_name (migrations.test_commands.MakeMigrationsTests.test_makemigrations_with_custom_name)
makemigrations --name generate a custom migration name.
----------------------------------------------------------------------
Traceback (most recent call last):
 
  File "C:\Python312\Lib\unittest\case.py", line 715, in fail
    raise self.failureException(msg)
    ^^^^^^^^^^^^^^^^^
AssertionError: 'dependencies=[]' not found in "#GeneratedbyDjango6.0.dev20250303103700on2025-03-0319:10\n\nfromdjango.dbimportmigrations,models\n\n\nclassMigration(migrations.Migration):
----------------------------------------------------------------------
Ran 17939 tests in 86.814s

FAILED (failures=10, errors=3, skipped=1373, expected failures=5)
Destroying test database for alias 'default'...
Ran 17939 tests in 86.814s

FAILED (failures=10, errors=3, skipped=1373, expected failures=5)

Ran 17939 tests in 86.814s

FAILED (failures=10, errors=3, skipped=1373, expected failures=5)
Destroying test database for alias 'default'....

Hi @adyaprasad — the only thing I can thing immediately is to make sure you’ve set Python into UTF-8 mode — that sometimes causes issues on Windows.

You should be able to clone the repo, create a virtual environment, and then run the tests so that they pass.

1 Like

Thanks for your advice @carltongibson ! I met the same issue and after following your advice I don’t meet errors or assertion failures anymore :slight_smile:
But an exception still happens for my tests, after searching in the forum I found a case that was exactly the same as mine, I’m wondering if you have any idea about it?

1 Like

Hello @carltongibson :folded_hands:

ull: Writing your first contribution for Django | Django documentation | Django

Running Django’s test suite for the first time

when I am running following command:

...\> runtests.py 

it does not run any test suite. So I think I can use it as:

...\> py runtests.py 

And at some moment, just I did it, I got tests fail issue.

[And ya, I have set Python into UTF-8 mode ]

am I doing correctly?

Probably yes. But there will be something about your environment that’s causing the issue. (Alas, I can’t say what from here.)

Might be worth trying in the WSL, to eliminate any Windows particularity.

(Often the Discord is better for questions that need more real time help…)

1 Like