33👍
Thanks to those who provided an answer to my question. I chose not to implement @amezhenin‘s solution as it was too different from how I run my tests and I didn’t want to change. @Oleksiy‘s solutions got rid of some logging messages but not all of them. I didn’t quite get what @gardenunez was getting at but that’s my fault.
After more research, I realized that I was specifying the nosetest argument incorrectly. It’s not --nocapture
as I indicated in my initial question but rather --nologcapture
. When I specified this argument, all of my logging messages were hidden.
6👍
You can always run nose with --logging-clear-handlers
to clear all other logging handlers.
- How to get user email with python social auth with facebook and save it
- Whats the correct format for django dateTime?
- How to output text from database with line breaks in a django template?
3👍
I can suggest you to put something like this into your settings.py
:
if 'test' in sys.argv:
# disable loggers output
LOGGING["loggers"] = {}
btw, I using nose
and doctests
for testing purposes so my full template looks like this:
if 'test' in sys.argv:
# add Nose to INSTALLED_APPS for running tests
INSTALLED_APPS = INSTALLED_APPS + ('django_nose',)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = ['--with-doctest']
# change DB to sqlite3, when running test for speedup
DATABASES['default'] = {'ENGINE': 'django.db.backends.sqlite3'}
# disable loggers output
LOGGING["loggers"] = {}
UPD. Forgot to tell that I run test with python manage.py test
, that is why I can refer to 'test'
in sys.argv
.
- 'CheckoutView' object has no attribute 'object'
- ForeignKey to a model that is defined after/below the current model
- Zip File downloaded from ReactJs/Axios is corrupted
- Appropriate choice of authentication class for python REST API used by web app
0👍
Try this:
logging.disable(logging.CRITICAL)
or logging.disable(logging.NOTSET)
It will disable logging calls with the specified severity level.
- How to test (using unittest) the HTML output of a Django view?
- Django sub-applications & module structure
- How to compare version string ("x.y.z") in MySQL?
- Django: Natural Sort QuerySet