mirror of https://github.com/django/django.git
Refs #27753 -- Removed django.test.utils.patch_logger() and str_prefix().
This commit is contained in:
parent
487d904bf2
commit
6d2ae49f25
|
@ -598,10 +598,6 @@ def compare_xml(want, got):
|
|||
return check_element(want_root, got_root)
|
||||
|
||||
|
||||
def str_prefix(s):
|
||||
return s % {'_': ''}
|
||||
|
||||
|
||||
class CaptureQueriesContext:
|
||||
"""
|
||||
Context manager that captures queries executed by the specified connection.
|
||||
|
@ -659,29 +655,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.
|
||||
|
||||
Use unittest.assertLogs() if you only need Python 3 support. This
|
||||
private API will be removed after Python 2 EOL in 2020 (#27753).
|
||||
"""
|
||||
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),
|
||||
|
|
|
@ -235,6 +235,22 @@ Dropped support for PostgreSQL 9.4
|
|||
Upstream support for PostgreSQL 9.4 ends in December 2019. Django 3.0 supports
|
||||
PostgreSQL 9.5 and higher.
|
||||
|
||||
Removed private Python 2 compatibility APIs
|
||||
-------------------------------------------
|
||||
|
||||
While Python 2 support was removed in Django 2.0, some private APIs weren't
|
||||
removed from Django so that third party apps could continue using them until
|
||||
the Python 2 end-of-life.
|
||||
|
||||
Since we expect apps to drop Python 2 compatibility when adding support for
|
||||
Django 3.0, we're removing these APIs at this time.
|
||||
|
||||
* ``django.test.utils.str_prefix()`` - Strings don't have 'u' prefixes in
|
||||
Python 3.
|
||||
|
||||
* ``django.test.utils.patch_logger()`` - Use
|
||||
:meth:`unittest.TestCase.assertLogs` instead.
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue