summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2018-04-28 15:20:27 +0200
committerTim Graham <timograham@gmail.com>2018-05-07 09:34:00 -0400
commit607970f31cc07c317f2ebb684c8f3ccc36a95b3e (patch)
treeb11c0976fb161d3339025400b048a27ce5e2f19f /django
parent7d3fe36c626a3268413eb86d37920f132eb4a54f (diff)
Replaced django.test.utils.patch_logger() with assertLogs().
Thanks Tim Graham for the review.
Diffstat (limited to 'django')
-rw-r--r--django/test/utils.py20
1 files changed, 0 insertions, 20 deletions
diff --git a/django/test/utils.py b/django/test/utils.py
index cbefaf0e09..6187d3e2be 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -634,26 +634,6 @@ class ignore_warnings(TestContextDecorator):
self.catch_warnings.__exit__(*sys.exc_info())
-@contextmanager
-def patch_logger(logger_name, log_level, log_kwargs=False):
- """
- Context manager that takes a named logger and the logging level
- and provides a simple mock-like list of messages received
- """
- calls = []
-
- def replacement(msg, *args, **kwargs):
- call = msg % args
- calls.append((call, kwargs) if log_kwargs else call)
- logger = logging.getLogger(logger_name)
- orig = getattr(logger, log_level)
- setattr(logger, log_level, replacement)
- try:
- yield calls
- finally:
- setattr(logger, log_level, orig)
-
-
# On OSes that don't provide tzset (Windows), we can't set the timezone
# in which the program runs. As a consequence, we must skip tests that
# don't enforce a specific timezone (with timezone.override or equivalent),