Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made SimpleTestCase client attributes cached properties. #14257

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions django/test/testcases.py
Expand Up @@ -43,7 +43,7 @@
override_settings,
)
from django.utils.deprecation import RemovedInDjango41Warning
from django.utils.functional import classproperty
from django.utils.functional import cached_property, classproperty
from django.utils.version import PY310
from django.views.static import serve

Expand Down Expand Up @@ -296,14 +296,20 @@ def _pre_setup(self):
* Create a test client.
* Clear the mail test outbox.
"""
self.client = self.client_class()
self.async_client = self.async_client_class()
mail.outbox = []

def _post_teardown(self):
"""Perform post-test things."""
pass

@cached_property
def client(self):
return self.client_class()

@cached_property
def async_client(self):
return self.async_client_class()

def settings(self, **kwargs):
"""
A context manager that temporarily sets a setting and reverts to the
Expand Down