Opened 5 years ago

Closed 2 years ago

Last modified 19 months 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 Changed 5 years ago by Paul Tiplady

Description: modified (diff)

comment:2 Changed 5 years ago by Paul Tiplady

Description: modified (diff)

comment:3 Changed 5 years ago by Jackie Leng

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 Changed 5 years ago by Eyad Toma

Owner: changed from nobody to Eyad Toma
Status: newassigned

comment:5 Changed 5 years ago by Mads Jensen

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 Changed 4 years ago by Hugo Osvaldo Barrera

Cc: Hugo Osvaldo Barrera added

comment:7 Changed 2 years ago by Baptiste Mispelon

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 Changed 2 years ago by Mariusz Felisiak

Needs tests: set

comment:9 Changed 2 years ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 9e565386:

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

comment:10 Changed 19 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 188f7786:

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

comment:11 Changed 19 months ago by Mariusz Felisiak <felisiak.mariusz@…>

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