How to specify verbosity level with 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 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/ test survey -v3 /home/bitnami/PycharmProjects/marketr
Testing started at 11:37 PM ...
Creating test database for alias 'default'...

Traceback (most recent call last):
  File "/home/bitnami/PycharmProjects/marketr/survey/", 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 file:

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

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


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)
Comment actions Permalink
Just curious: why aren't you using PyCharm's built in test runner? It gives you a graphical output that's much nicer than whatever test can print for you. Simply create a run configuration of type "Django tests" and specify the tests to run.
Comment actions Permalink
I AM using PyCharm's test runner and graphical interface. I get it automatically whether I choose from the menu or I right click on a specific function or method and choose to test. The middle column is the output of " test yourapp", right? The output appears to be identical to test -v1 (verbosity level=1).

My question is how to change verbosity level. Increasing to higher levels lets you know what is happening as the test database is being setup (post-syncdb signal handlers, custom SQL if any, initial data fixtures).

I'm only been developing a few months and have started working my way through a book about Django testing called "Django 1.1 Testing and Debugging" (though I'm using Django 1.4 and adapting). I've been able to duplicate everything to do with testing in the PyCharm environment except setting verbosity.

Please sign in to leave a comment.