0

How to specify verbosity level with manage.py test?

Using PyCharm 2.6.3 on both Windows and Linux.

For unit testing, sometimes it's useful to change verbosity level of output and Django gives you less or more information as desired. However, nothing seems to happen any different for v0, v1, v2, or v3. I think I'm always getting verbosity level 1. How do I change the verbosity level to something other than 1?

Here are the details of what I tried (app called "survey"):

Select manage.py
Select test (hit shift enter)
type: survey -v2

Pycharm accepts as valid input -v0, -v1, -v2, or -v3, as it should. But the output is always exactly the same (this example purposely has an error):

/opt/bitnami/python/bin/python2.7 /home/bitnami/pycharm-2.6.3/helpers/pycharm/django_test_manage.py test survey -v3 /home/bitnami/PycharmProjects/marketr
Testing started at 11:37 PM ...
Creating test database for alias 'default'...

Failure
Traceback (most recent call last):
  File "/home/bitnami/PycharmProjects/marketr/survey/tests.py", line 19, in test_basic_addition
    self.assertEqual(1 + 1, 3)
AssertionError: 2 != 3

Destroying test database for alias 'default'...

Process finished with exit code 1


and here's the tests.py file:

"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
Example of Docstring test:
1 + 1 == 2

True
"""

from django.test import TestCase


class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 3)

2 comments

Please sign in to leave a comment.