Revert "test_runner: Monkey-patch to allow using multiprocessing in tests."

This reverts commit 73eb0aa891.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-07-28 23:55:07 -07:00 committed by Anders Kaseorg
parent fa740c0435
commit 8c2d478e6a
1 changed files with 1 additions and 12 deletions

View File

@ -4,7 +4,7 @@ import random
import shutil import shutil
import unittest import unittest
from functools import partial from functools import partial
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, Union, cast from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, Union
from unittest import TestLoader, TestSuite, runner from unittest import TestLoader, TestSuite, runner
from unittest.result import TestResult from unittest.result import TestResult
@ -123,17 +123,6 @@ def run_subsuite(args: SubsuiteArgs) -> Tuple[int, Any]:
return subsuite_index, result.events return subsuite_index, result.events
# Monkey-patch django.test.runner to allow using multiprocessing
# inside tests without a “daemonic processes are not allowed to have
# children” error.
class NoDaemonContext(multiprocessing.context.ForkContext):
class Process(multiprocessing.context.ForkProcess):
daemon = cast(bool, property(lambda self: False, lambda self, value: None))
django_runner.multiprocessing = NoDaemonContext()
def destroy_test_databases(worker_id: Optional[int] = None) -> None: def destroy_test_databases(worker_id: Optional[int] = None) -> None:
for alias in connections: for alias in connections:
connection = connections[alias] connection = connections[alias]