Opened 19 months ago

Last modified 13 months ago

#21739 assigned Bug

When running tests fixture error output isn't visible

Reported by: camilo.lopez.a@… Owned by: Olek
Component: Testing framework Version: 1.6
Severity: Normal Keywords: test fixture verbosity
Cc: camilo.lopez.a@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by ramiro)

Hi,
On django 1.6, I'm running the command:

python manage.py test -v 2

One of my tests has a fixture and it seems that there is an issue with that, because no data is loaded and it's failing silently.
I was looking at the code of /django/test/testcase.py and I found this:

                call_command('loaddata', *self.fixtures,
                             **{'verbosity': 0, 'database': db_name, 'skip_validation': True})

So, verbosity is 0, hardcoded.
Shouldn't inherit the verbosity from the test command in manage.py somehow?

Change History (11)

comment:1 Changed 19 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Could you tell us what the issue with your fixtures is, and what is the output when verbosity > 0?

comment:2 Changed 19 months ago by camilo.lopez.a@…

The issue with the fixtures was that I hadn't a models.py file in my app, so all the fixtures where not recognized and it was filing silently.
I discovered the issue debugging on the source code of Django. I changed verbosity from 0 to 2 and was able to realise what was going on.

The models.py thing should be documented or better, change that behavior to just read from installed apps as one will expect.
call_command should inherit verbosity from the test command.

comment:3 Changed 19 months ago by mjtamlyn

models.py will not be required in 1.7. That said, the ticket is still a reasonable issue.

comment:4 Changed 19 months ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

I'm not sure it's a good idea to make fixture loading inherit verbosity from the test command. However, failure during loading fixtures should be loudly visible.

comment:5 Changed 19 months ago by camilo.lopez.a@…

If I give a command verbosity = X, I expect every procedure inside it to use that level of verbosity. If not, you will break consistency.

comment:6 Changed 18 months ago by anonymous

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned

comment:7 Changed 18 months ago by Olek

  • Owner changed from anonymous to Olek

comment:8 Changed 18 months ago by Olek

Working (but ugly) solution was moved into: https://github.com/django/django/pull/2299

comment:9 Changed 18 months ago by ramiro

  • Description modified (diff)

comment:10 Changed 18 months ago by ramiro

We've used and do currently have stealth options in management commands (flush, sql) so we have a precedent of that kind of options but so far we've used them to help in internal testing of infrastructure and not as something we allow the final user to control from the command line.

(btw, the reset_sequences stealth option of flush seems to be not used anymore.)

comment:11 Changed 13 months ago by timo

  • Has patch set
  • Patch needs improvement set
  • Summary changed from When running tests, the fixture loading process has verbosity = 0 hardcoded to When running tests fixture error output isn't visible

I don't think the current approach is desirable. We run the tests with -v 2 on our continuous integration and this would made the logs *much* nosier (lots of things like "No fixture 'authtestdata' in '/home/tim/code/django/tests/comment_tests/fixtures'."). Also the PR should be against master as we won't make the change in earlier versions.

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