Opened 5 years ago
Last modified 2 years ago
#31169 closed New feature
Parallel test mode not working on MacOS with recent versions of Python 3 — at Initial Version
Reported by: | Brandon Navra | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Ichlasul Affan, Ryan Siemens, Adam Wróbel | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Python 3.8 on MacOS has changed the default start method for the multiprocessing module from fork
to spawn
: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods.
When running tests with the --parallel
flag, this causes the worker processes to fail with django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
as they no longer have a copy of the parent memory state. It can also cause the workers to fail to find the cloned dbs ({{django.db.utils.OperationalError: FATAL: database "xxx_1" does not exist}}) as the db test prefix is missing.
I have attached a patch which changes django.test.runner._init_worker
(the worker initialiser for ParallelTestSuite
) to run django.setup() and set the db name to one with the test_
prefix.
Change History (1)
by , 5 years ago
Attachment: | Ensure_Django_is_setup_correctly_in_parallel_test_workers.patch added |
---|