Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable logging during manage.py test?

I utilize the standard python logging module. When I call python manage.py test I'd like to disable logging before all the tests are ran. Is there a signal or some other kind of hook I could use to call logging.disable? Or is there some other way to disable logging when python manage.py test is ran?

like image 856
Eric Palakovich Carr Avatar asked Jun 12 '10 22:06

Eric Palakovich Carr


People also ask

What does manage PY test do?

Running python manage.py test is the right way to run all the tests in your projects at once, your error is caused by something else. I think your problem is caused because you may have a tests folder within your tests folder, which is confusing unittest.

How do I enable logging in Django?

By default, the LOGGING setting is merged with Django's default logging configuration using the following scheme. If the disable_existing_loggers key in the LOGGING dictConfig is set to True (which is the dictConfig default if the key is missing) then all loggers from the default configuration will be disabled.


1 Answers

There is actually a much better way to do so, with django-nose there is a kwarg:

Just run:

./bin/manage.py test --logging-clear-handlers
like image 191
Rmatt Avatar answered Sep 23 '22 01:09

Rmatt