Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#27430 closed New feature (fixed)

`manage.py test` does not support unittest `-b` buffer option

Reported by: Paul Tiplady Owned by: Baptiste Mispelon
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Jackie Leng, Hugo Osvaldo Barrera Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Paul Tiplady)

Unittest supports buffering of test output with the -b flag, such that passing tests do not spam stdout/stderr with output. This is the default behaviour for nosetests, as well.

I can't see any way to enable this behaviour in manage.py test. Has adding support for this flag been considered?

Currently my workaround is to use nosetests (with django-nose), but that test runner appears to be bugged WRT the new --parallel flag, so it's not a perfect solution.

Change History (11)

comment:1 by Paul Tiplady, 7 years ago

Description: modified (diff)

comment:2 by Paul Tiplady, 7 years ago

Description: modified (diff)

comment:3 by Jackie Leng, 7 years ago

Cc: Jackie Leng added
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

Verified on master, there is no -b option or any option that seems to work the same way.

comment:4 by Eyad Toma, 7 years ago

Owner: changed from nobody to Eyad Toma
Status: newassigned

comment:5 by Mads Jensen, 7 years ago

There is a humble, yet incomplete attempt at this in https://github.com/atombrella/django/commit/4ada8bb0000106982f2cd5fb11e5ccdc278aa1c8 in case someone wants to complete it.

comment:6 by Hugo Osvaldo Barrera, 7 years ago

Cc: Hugo Osvaldo Barrera added

comment:7 by Baptiste Mispelon, 4 years ago

Has patch: set
Owner: changed from Eyad Toma to Baptiste Mispelon
Version: 1.10master

PR here

As noted in the PR, I couldn't figure out how to make the option work when running the tests in parallel.
Python's unittest implements the --buffer feature on its 'TestResult` class but Django reimplements that class from scratch in the case of parallel tests.

It might be possible to re-add all the stdout/stderr manupulation that Python does but even then I'm not sure how modifying sys.stdout would interact with multiprocessing (is it safe to do so?).

I didn't add any tests because I couldn't find examples in the existing test suite of how to construct a test case for this behavior.
(I used #30676 as a base to build this PR and it didn't come with tests either, but maybe that one was harder to test so it's more justified than for this ticket)

comment:8 by Mariusz Felisiak, 4 years ago

Needs tests: set

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 9e565386:

Fixed #27430 -- Added -b/--buffer option to DiscoverRunner.

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 188f7786:

Refs #27430 -- Added buffer argument to DiscoverRunner docs.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 7045fa7f:

[3.1.x] Refs #27430 -- Added buffer argument to DiscoverRunner docs.

Backport of 188f7786bc434a3e5ca7b46d2975a08318fe7452 from master

Note: See TracTickets for help on using tickets.
Back to Top