1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 08:26:03 +00:00

fix(tests): the parallel test runner works on Python 3.14; CI tests 3.14

Python 3.14 starts processes with forkserver, which Django 5.2's parallel
runner does not support: its workers import the tests before
django.setup() and fail (AppRegistryNotReady), and `--parallel` without a
number falls back to one process. The project's test runner sets the
start method to fork, as it was up to 3.13. The production image runs
Python 3.14 (Ubuntu 26.04): CI adds it, and the parallel run moves to that
leg.

Tried on Ubuntu 26.04's Python 3.14: `test --parallel 4` and `--parallel`
(8 processes) pass; before, both hung.
This commit is contained in:
catborise 2026-11-07 20:19:58 +03:00
parent f7c86ab05e
commit eb0343ee2f
3 changed files with 18 additions and 5 deletions

View file

@ -1,12 +1,24 @@
"""manage.py test --parallel on the SQLite database in WAL mode."""
import contextlib
import multiprocessing
import os
import secrets
from django.db import connections
from django.test.runner import DiscoverRunner
# Python 3.14 starts processes with forkserver on Linux, which Django 5.2's
# parallel runner does not support (a worker imports the tests before
# django.setup(), and --parallel without a number falls back to one process):
# fork there, as up to 3.13; macOS keeps spawn. Set on import: the command
# resolves --parallel while it parses.
if (
multiprocessing.get_start_method(allow_none=True) is None
and multiprocessing.get_all_start_methods()[0] == "forkserver"
):
multiprocessing.set_start_method("fork")
def remove_wal_files(name):
"""Django replaces a SQLite test database by its main file only. A run