From 6bb8258255cb2f739ba2a9a0af71b12d0b1f8af9 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 31 Jul 2015 12:45:27 -0400 Subject: [PATCH] [1.8.x] Fixed #25204 -- Added missing space in runserver logging. Backport of 1a76257b1b385ac8afd67bd36d061f508613e4d2 from master --- django/core/servers/basehttp.py | 2 +- tests/servers/test_basehttp.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index c663fd968d..2fa0f6c033 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -107,7 +107,7 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): def log_message(self, format, *args): - msg = "[%s]" % self.log_date_time_string() + msg = "[%s] " % self.log_date_time_string() try: msg += "%s\n" % (format % args) except UnicodeDecodeError: diff --git a/tests/servers/test_basehttp.py b/tests/servers/test_basehttp.py index 2f59b1358a..759ab522aa 100644 --- a/tests/servers/test_basehttp.py +++ b/tests/servers/test_basehttp.py @@ -12,6 +12,16 @@ class Stub(object): class WSGIRequestHandlerTestCase(TestCase): + + def test_log_message(self): + request = WSGIRequest(RequestFactory().get('/').environ) + request.makefile = lambda *args, **kwargs: BytesIO() + handler = WSGIRequestHandler(request, '192.168.0.2', None) + + with captured_stderr() as stderr: + handler.log_message('GET %s %s', 'A', 'B') + self.assertIn('] GET A B', stderr.getvalue()) + def test_https(self): request = WSGIRequest(RequestFactory().get('/').environ) request.makefile = lambda *args, **kwargs: BytesIO()