[Django] #36596: django_test_expected_failures has no effect on the parallel test runner in "spawn" mode

11 views
Skip to first unread message

Django

unread,
Sep 4, 2025, 4:12:49 PM (3 days ago) Sep 4
to django-...@googlegroups.com
#36596: django_test_expected_failures has no effect on the parallel test runner in
"spawn" mode
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Type: Bug
Status: new | Component: Testing
| framework
Version: dev | Severity: Normal
Keywords: multiprocessing | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The [https://docs.djangoproject.com/en/5.2/releases/3.2/#database-backends
django_test_expected_failures] method has no effect on the parallel test
runner in "spawn" multiprocessing mode, because it uses `setattr` to
[https://github.com/django/django/blob/4e7a991c12a113229e0927974d3bf94ea04eecf6/django/db/backends/base/creation.py#L365
monkey-patch] a class, and that patching is lost when workers are spawned.

To reproduce:
- add `multiprocessing.set_start_method("spawn")` near the top of
runtests.py if not running on MacOS or Windows
- adjust postgres database settings to include `"OPTIONS": {
"server_side_binding": True}` (to trigger an expected failure),
- `./runtests.py aggregation.tests --settings=test_postgres --parallel=1`
: passes
- `./runtests.py aggregation.tests --settings=test_postgres`: fails

Python will be defaulting all systems into "spawn" by default in Python
3.14, so we're about to see more traffic into this.
--
Ticket URL: <https://code.djangoproject.com/ticket/36596>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 4, 2025, 4:20:21 PM (3 days ago) Sep 4
to django-...@googlegroups.com
#36596: django_test_expected_failures has no effect on the parallel test runner in
"spawn" mode
-----------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: multiprocessing | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36596#comment:1>

Django

unread,
Sep 5, 2025, 7:04:31 AM (2 days ago) Sep 5
to django-...@googlegroups.com
#36596: django_test_expected_failures has no effect on the parallel test runner in
"spawn" mode
-----------------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: 2000023946
Type: Bug | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: multiprocessing | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by 2000023946):

* owner: (none) => 2000023946
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36596#comment:2>

Django

unread,
Sep 5, 2025, 7:10:35 AM (2 days ago) Sep 5
to django-...@googlegroups.com
#36596: django_test_expected_failures has no effect on the parallel test runner in
"spawn" mode
-----------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: multiprocessing | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by 2000023946):

* owner: 2000023946 => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/36596#comment:3>

Django

unread,
Sep 5, 2025, 8:00:34 AM (2 days ago) Sep 5
to django-...@googlegroups.com
#36596: django_test_expected_failures has no effect on the parallel test runner in
"spawn" mode
-----------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: multiprocessing | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Description changed by Jacob Walls:

Old description:

> The [https://docs.djangoproject.com/en/5.2/releases/3.2/#database-
> backends django_test_expected_failures] method has no effect on the
> parallel test runner in "spawn" multiprocessing mode, because it uses
> `setattr` to
> [https://github.com/django/django/blob/4e7a991c12a113229e0927974d3bf94ea04eecf6/django/db/backends/base/creation.py#L365
> monkey-patch] a class, and that patching is lost when workers are
> spawned.
>
> To reproduce:
> - add `multiprocessing.set_start_method("spawn")` near the top of
> runtests.py if not running on MacOS or Windows
> - adjust postgres database settings to include `"OPTIONS": {
> "server_side_binding": True}` (to trigger an expected failure),
> - `./runtests.py aggregation.tests --settings=test_postgres --parallel=1`
> : passes
> - `./runtests.py aggregation.tests --settings=test_postgres`: fails
>
> Python will be defaulting all systems into "spawn" by default in Python
> 3.14, so we're about to see more traffic into this.

New description:

The [https://docs.djangoproject.com/en/5.2/releases/3.2/#database-backends
django_test_expected_failures] attribute has no effect on the parallel
test runner in "spawn" multiprocessing mode, because it uses `setattr` to
[https://github.com/django/django/blob/4e7a991c12a113229e0927974d3bf94ea04eecf6/django/db/backends/base/creation.py#L365
monkey-patch] a class, and that patching is lost when workers are spawned.

To reproduce:
- add `multiprocessing.set_start_method("spawn")` near the top of
runtests.py if not running on MacOS or Windows
- adjust postgres database settings to include `"OPTIONS": {
"server_side_binding": True}` (to trigger an expected failure),
- `./runtests.py aggregation.tests --settings=test_postgres --parallel=1`
: passes
- `./runtests.py aggregation.tests --settings=test_postgres`: fails

Python will be defaulting all systems into "spawn" by default in Python
3.14, so we're about to see more traffic into this.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36596#comment:2>

Django

unread,
Sep 6, 2025, 2:48:25 AM (yesterday) Sep 6
to django-...@googlegroups.com
#36596: django_test_expected_failures has no effect on the parallel test runner in
"spawn" mode
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: titilayo
| odufowoke
Type: Bug | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: multiprocessing | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by titilayo odufowoke):

* owner: (none) => titilayo odufowoke
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36596#comment:3>
Reply all
Reply to author
Forward
0 new messages