djangotestingfixturesverbosity

How do I remove the "Installed x object(x) from y fixture(s)" report from django test?


I am using fixtures during my django tests as they are proving to be quite useful

def some_test(self):
    ...
    call_command('loaddata', 'path/to/fixture.json')
    ...
    self.assertTrue(...)

And when I run my tests, they all pass:

$ python manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
..Installed 2 object(s) from 1 fixture(s)
......................................
----------------------------------------------------------------------
Ran 40 tests in 0.104s

OK
Destroying test database for alias 'default'...

However, the "Installed 2 object(s) from 1 fixture(s)" is starting to annoy me.

Is there a way to reduce the verbosity of the command? So then it could look like:

$ python manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
........................................
----------------------------------------------------------------------
Ran 40 tests in 0.104s

OK
Destroying test database for alias 'default'...

Which is what I want


Solution

  • call_command('loaddata', '-v', '0', 'path/to/fixture.json')
    

    This will set the verbosity to 0, meaning that nothing will be reported unless something goes terribly wrong.