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 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'...
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
from django.test import TestCase
Tests that 1 + 1 always equals 2.
self.assertEqual(1 + 1, 3)
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 manage.py test can print for you. Simply create a run configuration of type "Django tests" and specify the tests to run.
Dmitry Jemerov, Chief Technology Officer, JetBrains
I AM using PyCharm's test runner and graphical interface. I get it automatically whether I choose manage.py from the menu or I right click on a specific function or method and choose to test. The middle column is the output of "manage.py test yourapp", right? The output appears to be identical to manage.py 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.
Structure Expansion Not Working
Cann't automatic completion code with the instance via copy and deepcopy
Build #178 (Dec/17/2014 3:47PM)