Hello @kartik,
Since you are in Django, you could add these lines to your settings.py:
import sys
import logging
if len(sys.argv) > 1 and sys.argv[1] == 'test':
logging.disable(logging.CRITICAL)
That way you don't have to add that line in every setUp() on your tests.
You could also do a couple of handy changes for your test needs this way.
There is another "nicer" or "cleaner" way to add specifics to your tests and that is making your own test runner.
Just create a class like this:
import logging
from django.test.simple import DjangoTestSuiteRunner
from django.conf import settings
class MyOwnTestRunner(DjangoTestSuiteRunner):
def run_tests(self, test_labels, extra_tests=None, **kwargs):
# Don't show logging messages while testing
logging.disable(logging.CRITICAL)
return super(MyOwnTestRunner, self).run_tests(test_labels, extra_tests, **kwargs)
And now add to your settings.py file:
TEST_RUNNER = "PATH.TO.PYFILE.MyOwnTestRunner"
#(for example, 'utils.mytest_runner.MyOwnTestRunner'
Hope this is helpfull!
Thank You!