mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Refs #34986 -- Moved garbage_collect() helper to django.test.utils.
This commit is contained in:
parent
1c3614e306
commit
fb9216382a
@ -1,4 +1,5 @@
|
|||||||
import collections
|
import collections
|
||||||
|
import gc
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -27,6 +28,7 @@ from django.template import Template
|
|||||||
from django.test.signals import template_rendered
|
from django.test.signals import template_rendered
|
||||||
from django.urls import get_script_prefix, set_script_prefix
|
from django.urls import get_script_prefix, set_script_prefix
|
||||||
from django.utils.translation import deactivate
|
from django.utils.translation import deactivate
|
||||||
|
from django.utils.version import PYPY
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import jinja2
|
import jinja2
|
||||||
@ -38,6 +40,7 @@ __all__ = (
|
|||||||
"Approximate",
|
"Approximate",
|
||||||
"ContextList",
|
"ContextList",
|
||||||
"isolate_lru_cache",
|
"isolate_lru_cache",
|
||||||
|
"garbage_collect",
|
||||||
"get_runner",
|
"get_runner",
|
||||||
"CaptureQueriesContext",
|
"CaptureQueriesContext",
|
||||||
"ignore_warnings",
|
"ignore_warnings",
|
||||||
@ -982,3 +985,10 @@ def register_lookup(field, *lookups, lookup_name=None):
|
|||||||
finally:
|
finally:
|
||||||
for lookup in lookups:
|
for lookup in lookups:
|
||||||
field._unregister_lookup(lookup, lookup_name)
|
field._unregister_lookup(lookup, lookup_name)
|
||||||
|
|
||||||
|
|
||||||
|
def garbage_collect():
|
||||||
|
gc.collect()
|
||||||
|
if PYPY:
|
||||||
|
# Collecting weakreferences can take two collections on PyPy.
|
||||||
|
gc.collect()
|
||||||
|
@ -1,23 +1,9 @@
|
|||||||
import gc
|
|
||||||
import weakref
|
import weakref
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
|
|
||||||
from django.dispatch import Signal, receiver
|
from django.dispatch import Signal, receiver
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import garbage_collect, 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()
|
|
||||||
|
|
||||||
|
|
||||||
def receiver_1_arg(val, **kwargs):
|
def receiver_1_arg(val, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user