I’m not sure if I’ve hit a bug or I’m holding it wrong. In my project I use a custom test runner which overrides a few Django settings (adds MD5 password hasher to PASSWORD_HASHERS for speed, stuff like that).
The test suite runs fine both sequentially and in parallel on Python 3.12. It also runs fine sequentially on Python 3.14. But when running in parallel on Python 3.14 it appears as if Django doesn’t see the settings I’ve set in the custom test runner.
A minimal reproducer:
- create a new project with
django-admin startproject fooproject - create two files with identical contents,
fooproject/tests.pyandfooproject/tests_more.py
Contents for both files:
from django.conf import settings
from django.test import TestCase
from django.test.runner import DiscoverRunner
class MyRunner(DiscoverRunner):
def setup_test_environment(self):
settings.WORLD = "World"
super().setup_test_environment()
class MyTestCase(TestCase):
def test_it_works(self):
print(f"Hello {settings.WORLD}")
Run tests like so:
./manage.py test --parallel --testrunner fooproject.tests.MyRunner
This works on Python 3.12 (prints out “Hello World” twice), but on Python 3.14, produces an error: AttributeError: 'Settings' object has no attribute 'WORLD'
I am aware of #36531 (Add "forkserver" support to parallel test runner.) – Django but am unfamiliar with anything-multiprocessing and so not sure how to proceed.