[Django] #22439: LiveServerTestCase handles error messages inconsistently

45 views
Skip to first unread message

Django

unread,
Apr 14, 2014, 4:17:20 PM4/14/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+--------------------
Reporter: jmbowman | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
There are a few different ways that messages can be output when running
LiveServerTestCase, and they aren't currently handled consistently:

* Messages that are created via the logging module are handled normally
with the exception of console output, which is typically captured by the
test runner and shown only for failures. This is usually what is desired.

* Request status messages are normally sent to stdout by Django's
WSGIRequestHandler, but QuietWSGIRequestHandler doesn't output them at all
to avoid interfering with the test runner output. This makes the
information unavailable when debugging test failures.

* PEP 333 (WSGI) suggests sending error messages to the wsgi.errors
stream, which even for QuietWSGIRequestHandler is currently stderr. These
can interfere with the test runner output.

* Some less serious errors instead get sent to
socketserver.BaseServer.handle_error() (inherited by WSGIServer), which
since at least Python 2.7 has sent different parts of the output directly
to stdout and stderr (there's a comment in the CPython source pointing out
that this is less than ideal). Errors like "[Errno 32] Broken pipe"
(which sometimes happens when a browser cancels a request before it
finishes) can end up here and really clutter the test output.

None of this should go to stderr or stdout when running a
LiveServerTestCase, and most (maybe all) of it should be available via the
configured logging handlers (probably via the "django.request" logger).

--
Ticket URL: <https://code.djangoproject.com/ticket/22439>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 14, 2014, 4:26:54 PM4/14/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
-------------------------------------+-------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jmbowman):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => jmbowman
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:1>

Django

unread,
Apr 14, 2014, 4:59:23 PM4/14/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
-------------------------------------+-------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: | Status: assigned
Cleanup/optimization | Version: 1.6
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jmbowman):

* has_patch: 0 => 1


Comment:

Proposed fix is in https://github.com/jmbowman/django/tree/ticket_22439
(now looking into possible unit tests for it).

--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:2>

Django

unread,
Apr 14, 2014, 5:09:33 PM4/14/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: Cleanup/optimization | Status: assigned

Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by julien):

* needs_docs: 0 => 1
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:3>

Django

unread,
Apr 15, 2014, 11:28:49 AM4/15/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by jmbowman):

Unit tests are written and passing in at least Python 2.7 and 3.4. Pull
request has been generated and is ready for review:
https://github.com/django/django/pull/2557

--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:4>

Django

unread,
Apr 15, 2014, 4:39:17 PM4/15/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by julien):

Thanks a lot, the patch looks great. Could you just add a little bit of
documentation explaining how information/errors are logged with LSTC?

--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:5>

Django

unread,
May 7, 2014, 10:48:36 PM5/7/14
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by ramiro):

As noted in a comment there. This would also solve issue #21227.

--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:6>

Django

unread,
Jan 23, 2015, 7:46:51 AM1/23/15
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+------------------------------------
Reporter: jmbowman | Owner: jmbowman
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by jaywink):

Tested by merging (and resolving conflicts) on top of 1.6.10 at least and
works well.

Incidentally, the "''Errors like "[Errno 32] Broken pipe" (which sometimes


happens when a browser cancels a request before it finishes) can end up

here and really clutter the test output.'' " part is also solved by this
commit going to 1.8 next release:
https://github.com/django/django/commit/9253042d53d61b23b3f727a00c41e8089be73836
. Verified merging this in to 1.6.10 this too.

--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:7>

Django

unread,
Feb 28, 2021, 10:27:50 AM2/28/21
to django-...@googlegroups.com
#22439: LiveServerTestCase handles error messages inconsistently
--------------------------------------+------------------------------------
Reporter: Jeremy Bowman | Owner: (none)

Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):

* owner: Jeremy Bowman => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/22439#comment:8>

Reply all
Reply to author
Forward
0 new messages