1
0
mirror of https://github.com/django/django.git synced 2024-12-22 00:55:44 +00:00

Refs #34986 -- Moved garbage_collect() helper to django.test.utils.

This commit is contained in:
Nick Pope 2023-12-04 11:23:08 +00:00 committed by Mariusz Felisiak
parent 1c3614e306
commit fb9216382a
2 changed files with 11 additions and 15 deletions

View File

@ -1,4 +1,5 @@
import collections
import gc
import logging
import os
import re
@ -27,6 +28,7 @@ from django.template import Template
from django.test.signals import template_rendered
from django.urls import get_script_prefix, set_script_prefix
from django.utils.translation import deactivate
from django.utils.version import PYPY
try:
import jinja2
@ -38,6 +40,7 @@ __all__ = (
"Approximate",
"ContextList",
"isolate_lru_cache",
"garbage_collect",
"get_runner",
"CaptureQueriesContext",
"ignore_warnings",
@ -982,3 +985,10 @@ def register_lookup(field, *lookups, lookup_name=None):
finally:
for lookup in lookups:
field._unregister_lookup(lookup, lookup_name)
def garbage_collect():
gc.collect()
if PYPY:
# Collecting weakreferences can take two collections on PyPy.
gc.collect()

View File

@ -1,23 +1,9 @@
import gc
import weakref
from types import TracebackType
from django.dispatch import Signal, receiver
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.utils.version import PYPY
if PYPY:
def garbage_collect():
# Collecting weakreferences can take two collections on PyPy.
gc.collect()
gc.collect()
else:
def garbage_collect():
gc.collect()
from django.test.utils import garbage_collect, override_settings
def receiver_1_arg(val, **kwargs):